dgvChangeUserName.DataSource = _objProducts.GetAllProductsinUserName(mam._objAdmin.CustomerID, mam._objAdmin.IsAdmin);
Rectangle rect = dgvChangeUserName.GetCellDisplayRectangle(0, -1, true);
rect.Y = 3;
rect.X = rect.Location.X + (rect.Width / 4)-2;
CheckBox checkboxHeader = new CheckBox();
checkboxHeader.Name = "checkboxHeader";
//datagridview[0, 0].ToolTipText = "sdfsdf";
checkboxHeader.Size = new Size(18, 18);
checkboxHeader.Location = rect.Location;
checkboxHeader.CheckedChanged += new EventHandler(checkboxHeader_CheckedChanged);
dgvChangeUserName.Controls.Add(checkboxHeader);
void checkboxHeader_CheckedChanged(object sender, EventArgs e)
{
CheckBox cbx=(CheckBox) sender;
if (dgvChangeUserName.Rows[0].Cells.Count > 2)
{
dgvChangeUserName.Rows[0].Cells[2].Selected = true;
dgvChangeUserName.Rows[0].Cells[2].Selected = false;
}
for (int intLoop = 0; intLoop < dgvChangeUserName.Rows.Count; intLoop++)
{
dgvChangeUserName.Rows[intLoop].Cells[0].Value = cbx.Checked;
}
}
No comments:
Post a Comment