Abdu Rafeeq

Abdu Rafeeq

  • NA
  • 113
  • 264.7k

Call Function

Jun 10 2011 6:51 AM
I have two fuctions, they are given below

private void Form1_Load(object sender, EventArgs e)
{
//DgvColumnHeaderMerge d_obj = new DgvColumnHeaderMerge();
Form1 d_obj = new Form1();
this.dataGridView1.Columns.Add("dept_name", "Name");
this.dataGridView1.Columns.Add("dept_code", "Code");
this.dataGridView1.Columns.Add("emp_name", "Name");
this.dataGridView1.Columns.Add("emp_place", "Place");
this.dataGridView1.Columns.Add("emp_phone", "Phone No");
// RowCreated(dataGridView2,e);
//dataGridView2.Rows.Add();


}
void dataGridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
//Build custom header.
GridView oGridView = (GridView)sender;
//DataGridView oGridView = (DataGridView)sender;
GridViewRow oGridViewRow =
new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
TableCell oTableCell = new TableCell();
//Add Department
oTableCell.Text = "Department";
oTableCell.ColumnSpan = 2;
oGridViewRow.Cells.Add(oTableCell);
//Add Employee
oTableCell = new TableCell();
oTableCell.Text = "Employee";
oTableCell.ColumnSpan = 3;
oGridViewRow.Cells.Add(oTableCell);
oGridView.Controls[0].Controls.AddAt(0, oGridViewRow);
}
}

How  call the function?

void dataGridView1_RowCreated(object sender, GridViewRowEventArgs e)

to form load?


here i want to sub header row for header row in datagrid view of windows application


Answers (1)