hi to all
I have follwoing code in desktop application ..
see out put snashot too ..Code:private void Form1_Load(object sender, EventArgs e) { this.dataGridView1.Visible = false; DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn(); // column.HeaderText = "All"; // c1.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; column.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; column.Name = "Selected"; //column.AutoSizeMode = this.dataGridView1.Columns.Add(column); ckBox = new CheckBox(); //Get the column header cell bounds Rectangle rect = this.dataGridView1.GetCellDisplayRectangle(0, -1, true); ckBox.Size = new Size(18, 18); //Change the location of the CheckBox to make it stay on the header ckBox.Location = rect.Location; ckBox.CheckedChanged += new EventHandler(ckBox_CheckedChanged); //Add the CheckBox into the DataGridView this.dataGridView1.Controls.Add(ckBox); //DataGridViewAutoSizeColumnMode.DisplayedCells; //column.FlatStyle = FlatStyle.Standard; //column.ThreeState = false; //column.CellTemplate = new DataGridViewCheckBoxCell(); //column.CellTemplate.Style.BackColor = Color.Beige; // dataGridView1.Columns.Insert(0, column); // This is to be a checkbox column //Rectangle rect = dataGridView1.GetCellDisplayRectangle(0, -1, true); //// set checkbox header to center of header cell. +1 pixel to position correctly. //rect.X = rect.Location.X + (rect.Width / 4); //CheckBox checkboxHeader = new CheckBox(); //checkboxHeader.Name = "checkboxHeader"; //checkboxHeader.Size = new Size(18, 18); //checkboxHeader.Location = rect.Location; //checkboxHeader.CheckedChanged += new EventHandler(checkboxHeader_CheckedChanged); // dataGridView1.Controls.Add(checkboxHeader); //this.dataGridView1.bin } void ckBox_CheckedChanged(object sender, EventArgs e) { for (int j = 0; j < this.dataGridView1.RowCount; j++) { this.dataGridView1[0, j].Value = this.ckBox.Checked; } this.dataGridView1.EndEdit(); }
can any one tell me how to put header text box shown in image in the column where written selected.please necessary ammendmnet in code


Reply With Quote
