C# (C Sharp) Beginner | Tutorial | Learning | Study
C# (C Sharp) Beginner | Tutorial | Learning | Study
Showing posts with label
C#
.
Show all posts
Showing posts with label
C#
.
Show all posts
6 August 2016
Add Item in Datagridview Combobox Column in C#
DatagridviewComboBox otype = new DatagridviewComboBox ( );
otype.Items.Add("Item1");
otype.Items.Add("Item2");
5 August 2016
Delete selected Multiple Rows in Datagridview in C#
foreach(DataGridViewRow dR in DGV.SelectedRows)
{
DGV.Rows.Remove(dR);
}
That's All; Simple....!
Thank you!
4 August 2016
Switch case in C#
private void DGV_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
switch (e.ColumnIndex)
{
case 1:
p1.cmd = new OleDbCommand("select pname from pmaster where code='" + DGV[e.ColumnIndex, e.RowIndex].Value + "'", p1.Cn);
p1.rs = p1.cmd.ExecuteReader();
if(p1.rs.Read()) DGV[e.ColumnIndex + 1, e.RowIndex].Value = p1.rs[0];
break;
case 2:
break;
default:
break;
}
}
3 August 2016
Add Rows and Row Data by Programmatically in Datagridview C#
DGV.Rows.Add("1", "2", "3", "4", "etc");
Write
murugankarthik008@gmail.com
for more.
Fill Controls by Double click Cell in datagridview in C#
private void DGV_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
C1.Text = DGV["lno", e.RowIndex].Value.ToString();
DT.Value = Convert.ToDateTime(DGV["date1", e.RowIndex].Value);
C2.Text = DGV["pcode", e.RowIndex].Value.ToString();
textBox11.Text = DGV["tcode", e.RowIndex].Value.ToString();
C3.Text = DGV["pname", e.RowIndex].Value.ToString();
C4.Text = DGV["sname", e.RowIndex].Value.ToString();
C5.Text = DGV["type1", e.RowIndex].Value.ToString();
C6.Text = DGV["type2", e.RowIndex].Value.ToString();
textBox1.Text = DGV["qty", e.RowIndex].Value.ToString();
textBox2.Text = DGV["gram", e.RowIndex].Value.ToString();
}
Write to
murugankarthik@gmail.com
for more.
Set Columns in Datagridview C#
void seTFlx()
{
DataGridViewTextBoxColumn cS = new DataGridViewTextBoxColumn();
DataGridViewComboBoxColumn cBc = new DataGridViewComboBoxColumn();
DataGridViewComboBoxColumn cBc1 = new DataGridViewComboBoxColumn();
cS.HeaderText = "S.No";
cBc.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
p1.cmd = new OleDbCommand("select pname from pmaster", p1.Cn);
p1.rs = p1.cmd.ExecuteReader();
while (p1.rs.Read())
{
cBc.Items.Add(p1.rs[0]);
cBc1.Items.Add(p1.rs[0]);
}
DGV.Columns.Add(cS);
DGV.Columns.Add(cBc);
DGV.Columns.Add(cBc1);
DGV.Rows.Add(100);
for (int s = 0; s < 100; s++)
{
DGV[0, s].Value = s + 1;
}
DGV.Columns[0].ReadOnly = true;
}
23 July 2016
Crystal Report in C#
1) Add Reference as following
2) Add Axcrviewer9Lib view in form from Toolbox and rename control to
CRV
3)
Then copy this to your code section
private void print_Load(object sender, EventArgs e)
{
CRAXDRT.Application crep = new CRAXDRT.Application();
CRAXDRT.Report frep = new CRAXDRT.Report();
this.Text = "Test Print";
frep = crep.OpenReport("D:/Sofwares/Adagu/loan_rep.rpt", 1);
p1.cmd = new OleDbCommand("select *,'Loan Report' as rname from loan", p1.Cn);
p1.rs = p1.cmd.ExecuteReader();
p1.rs.Read();
frep.Database.SetDataSource(p1.rs);
CRV.ViewReport();
MessageBox.Show("Printed Successful");
}
For more Details Mail to
murugankarthik008@gmail.com
MsAccess Database Connection with C#
using System.Data.OleDb;
Cn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Data.mdb");
Cn.Open();
How to save datagridview to access database c#
for(int i = 0; i < DGV.Rows.Count - 1; i++)
{
p1.cmd = new OleDbCommand("insert into pmaster(name,sname,type,gro,code,odate) values ('" + C2.Text.Trim() + "','" + DGV[1,i]+"','"+C3.Text+"','"+C1.Text.Trim()+"','"+textBox1.Text.Trim()+"','"+DateTime.Now.Date+"')",p1.Cn);
p1.cmd.ExecuteNonQuery();
}
How to save datagridview to access database c#
for(int i = 0; i < DGV.Rows.Count - 1; i++)
{
p1.cmd = new OleDbCommand("insert into pmaster(name,sname,type,gro,code,odate) values ('" + C2.Text.Trim() + "','" + DGV[1,i]+"','"+C3.Text+"','"+C1.Text.Trim()+"','"+textBox1.Text.Trim()+"','"+DateTime.Now.Date+"')",p1.Cn);
p1.cmd.ExecuteNonQuery();
}
how to get checkbox value in c#
p1.cmd = new OleDbCommand("insert into pass(name,pass,type1,add,edit,dele) values ('" + C1.Text.Trim() + "','" + textBox1.Text + "','" + C2.Text + "'," + (Ck1.Checked ? 1 : 0) + "," + (Ck2.Checked ? 1 : 0) + "," + (Ck3.Checked ? 1 : 0) + ")", p1.Cn);
here we get ck1.checked?1:0 = 1 while checked;
ck1.checked?1:0 = 0 while Unchecked;
Thank you !
Create Text file (or any basic format files) in C#
using System.IO;
StreamWriter File = new StreamWriter("Bar.txt");
File.Write("<html>");
File.Write("<title>Test File</title>");
File.Write("<head></head>");
File.Write("<body bgcolor=blue>Hai This is Test Body</body></html>");
File.Close();
System.Diagnostics.Process.Start("Bar.txt");
Suggest Blog for daily News in Tamil:
tamizhnewz.blogspot.in
Print File to Printer Different ways C#
Easy way to print file:
PrintDocument pd = new PrintDocument();
pd.PrinterSettings.PrinterName = "Hp Printer";
pd.DocumentName = "Bar.txt";
pd.Print();
MessageBox.Show("Printer: Hp Printer" + " " + "\nFile: Bar.txt");
Another way to Print File:
private void button1_Click(object sender, EventArgs e)
{
System.IO.StreamReader filetoprint;
filetoprint = new System.IO.StreamReader(@"D:\\m.txt");
printDocument1.Print();
filetoprint.Close();
}
Another way to Print File:
var pi=new ProcessStartInfo("C:\file.docx");
pi.UseShellExecute = true;
pi.Verb = "print";
var process = System.Diagnostics.Process.Start(pi);
Suggest Blog for daily News in Tamil:
tamizhnewz.blogspot.in
Array in C#
Array
------
int[] myarray = { 100,200,300,400,500 };
string[] myarray = { "s1","s2","s3","s4","s5" };
Older Posts
Home
Subscribe to:
Posts (Atom)