To merge Cell in DataGridView You Have to Fire Paint event
after that give the RowHeight and RowWidth and number of cell to be merged
Code is Given below
dataGridView1.Paint += new PaintEventHandler(dataGridView1_Paint);
void dataGridView1_Paint(object sender, PaintEventArgs e)
{
Rectangle rct;
rct = e.ClipRectangle;
rct.X = dataGridView1.GetColumnDisplayRectangle(0, true).X;
rct.Y = dataGridView1.GetRowDisplayRectangle(6, true).Y;//here 6 is the ROW Number which you want to Merge
rct.Height = dataGridView1.Rows[1].Height;//.Cells[0].Size.Height;
rct.Width = dataGridView1.Rows[2].Cells[0].Size.Width * 4;// 4 is the no of cell to be merged
OR
rct.Width = dataGridView1.Width; // its Automatically Merge all the Cell of a ROW
e.Graphics.FillRectangle(Brushes.White, rct);
Pen p = new Pen(SystemColors.ControlDark);
e.Graphics.DrawRectangle(p, rct);
e.Graphics.DrawString("Total Salary " + SalarySum,new System.Drawing.Font("Arial",10,FontStyle.Bold ) ,Brushes.Blue, rct.X, Rect.Y);
}
Tuesday, May 25, 2010
Thursday, May 20, 2010
Bind Data in DataGridView
string strSQLconnection = "Data Source=(local);Initial Catalog=Info;Integrated Security=True";
SqlConnection sqlConnection = new SqlConnection(strSQLconnection);
SqlCommand sqlCommand = new SqlCommand("select * from product", sqlConnection);
sqlConnection.Open();
SqlDataAdapter sda = new SqlDataAdapter(sqlCommand.CommandText, sqlConnection);
DataSet ds = new DataSet();
sda.Fill(ds);
DataGrid1.DataSource = ds.Tables[0];
SqlConnection sqlConnection = new SqlConnection(strSQLconnection);
SqlCommand sqlCommand = new SqlCommand("select * from product", sqlConnection);
sqlConnection.Open();
SqlDataAdapter sda = new SqlDataAdapter(sqlCommand.CommandText, sqlConnection);
DataSet ds = new DataSet();
sda.Fill(ds);
DataGrid1.DataSource = ds.Tables[0];
Tuesday, May 18, 2010
How To Change Localization of Window Application in C#
To Change localization
Take a Combo Box and add item
Hindi
English
Chinese
suppose there is a Label1 on the Form and its Text Property is= Nagendra
and we want to change its Culture according To Language in
Hindi= नागेन्द्र
Chinies=納根德拉
To do this go on the form and set its Property Localizable =True
Now set the language of Form is Hindi and set Label1.text= नागेन्द्र
Now a new .resx file will be made like Form1.hi.resx
Now set the language of Form is Chinies and set Label1.text=納根德拉
Now a new .resx file will be made like Form1.zh-CHT.resx
private void ChangeLanguage(string lang)
{
foreach (Control c in this.Controls)
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(Form1));
resources.ApplyResources(c, c.Name, new CultureInfo(lang));
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex == 0)
{
ChangeLanguage("hi");
}
if (comboBox1.SelectedIndex == 1)
{
ChangeLanguage("en");
}
else if(comboBox1.SelectedIndex==2)
{
ChangeLanguage("zh-CHT");
}
}
Here we have used hi is for Hindi,zh-CHT for Chinies it is specific for every Language
Take a Combo Box and add item
Hindi
English
Chinese
suppose there is a Label1 on the Form and its Text Property is= Nagendra
and we want to change its Culture according To Language in
Hindi= नागेन्द्र
Chinies=納根德拉
To do this go on the form and set its Property Localizable =True
Now set the language of Form is Hindi and set Label1.text= नागेन्द्र
Now a new .resx file will be made like Form1.hi.resx
Now set the language of Form is Chinies and set Label1.text=納根德拉
Now a new .resx file will be made like Form1.zh-CHT.resx
private void ChangeLanguage(string lang)
{
foreach (Control c in this.Controls)
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(Form1));
resources.ApplyResources(c, c.Name, new CultureInfo(lang));
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex == 0)
{
ChangeLanguage("hi");
}
if (comboBox1.SelectedIndex == 1)
{
ChangeLanguage("en");
}
else if(comboBox1.SelectedIndex==2)
{
ChangeLanguage("zh-CHT");
}
}
Here we have used hi is for Hindi,zh-CHT for Chinies it is specific for every Language
Subscribe to:
Posts (Atom)
Mat Table Angular
Mat Table in Angular Mat table is used to display data . its a material designed styled data-table . For using Material Table MatTableMo...
-
CriteriaOperator criteria = new BinaryOperator("Age", 30, BinaryOperatorType.Greater); CriteriaOperator criteria = CriteriaOperato...
-
SortingCollection sc = new SortingCollection(); sc.Add (new SortProperty("field on which you want to sort",DevExpress.Xpo.DB.Sorti...
-
Here ItemName will be Enable/Disable According to IsApplicable Property Assembly: DevExpress.XtraLayout; DevExpress.ExpressApp.Win.Layou...