We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do i add checkbox header cell

Thread ID:

Created:

Updated:

Platform:

Replies:

2427 Jan 17,2003 12:54 PM UTC Jan 20,2003 07:10 PM UTC Windows Forms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On January 17, 2003 12:54 PM UTC

Hi, I am using a GridDataBoundGrid. I have a bool column. I made the celltype of the bound column as "CheckBox". Instead of displaying a button, I want to display a checkbox in the header cell. When ever the user checks/unchecks the header checkbox, I want to toggle all checkboxes in the column. I tried setting gridDataBoundGrid1[0, 1].CellType = "CheckBox"; But I am still getting a header button instead of checkbox. What am I doing wrong? thanks, - Reddy

Administrator [Syncfusion]
Replied On January 17, 2003 11:07 PM UTC

In a GridDataBoundGrid, you cannot use an indexer to set individual cell style properties (other than Text). The reason is that there is no data object allocated to save these properties. The only cell data is the data from your DataSource (this is why you can set the Text property as it is mapped to the data in your datasource, but you cannot set other cell properties.) So, to do something like this, you can use the Model.QueryCellInfo to set these properties, and then handle the grid's click event to toggle the setting. Attached is a rough try at this.

Administrator [Syncfusion]
Replied On January 20, 2003 02:40 PM UTC

Clay, Thank you very much for your help. There is one problem with the sample. When I double click on the checkbox header, it is sorting the column. After that, when I try to click on header checkbox, it is not working properly. It is sorting the column dynamically. SortBehaviour is for the whole grid. Can I disable sorting for just one column? thanks, - Reddy

Administrator [Syncfusion]
Replied On January 20, 2003 07:10 PM UTC

If you derive the GridDataBoundGrid, you can override OnCellDoubleClick and avoid the sort at that point.
public class MyGridDataBoundGrid : GridDataBoundGrid
{
	protected override void OnCellDoubleClick(GridCellClickEventArgs e)
	{
		if(e.ColIndex == 3 && e.RowIndex == 0)
			return;
		base.OnCellDoubleClick(e);
	}
}

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;