Click here to Skip to main content
15,664,272 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Code for inserting checkbox in header of datagridview

private void show_chkBox()
{
Rectangle rect =dgvQueryResults.GetCellDisplayRectangle(0, -1, true);
// set checkbox header to center of header cell. +1 pixel to position
rect.Y = 3;
rect.X = rect.Location.X + (rect.Width / 4);
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);
dgvQueryResults.Controls.Add(checkboxHeader);
}

but error iam getting is

Specified argument was out of the range of valid values.
Parameter name: columnIndex

Any help
Posted
Updated 17-Oct-13 22:57pm
v2

1 solution

I think your error very clearly: Specified argument was out of the range of valid values.
Parameter name: columnIndex
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900