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

FilterBar for CheckBox type column

Thread ID:

Created:

Updated:

Platform:

Replies:

17472 Aug 10,2004 01:22 AM UTC Aug 10,2004 05:24 PM UTC Windows Forms 2
loading
Tags: GridControl
Bidin Dinesababu
Asked On August 10, 2004 01:22 AM UTC

Hi, I have a databound grid with one column with CHECKBOX style. Data is 1 and 0. If 1, the cell is checked and if 0 it is unchecked. It is working properly. I need to display "Yes" and "No" as my filter options in my filterbar for the column. Is there any option for doing this. Any help in this regard is really appreciated. Thanks in advance, Bidin

Administrator [Syncfusion]
Replied On August 10, 2004 05:40 AM UTC

There are no property setting that will do this for you. You can handle the CurrrentCellShowingDropDown event. You can swap out the datasource for the dropdown at that point. In the new datasource, you would have a display member column showing yes/no and a Value member column returning the 1 and 0 that is used by your normal column. Here is a rough snippet. (Did not actually try this, so don''t know if you will have to change the typeof(int) to something else that better matches the type of the actual column you are using. (Mayen string, maybe bool).
private void gridDataBoundGrid1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid.CurrentCell;
	if(cc.ColIndex == 2 && cc.RowIndex == 1)
 	{
		GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
		if(cr != null)
		{
			DataTable dt = new DataTable("YesNo");
			dt.Columns.Add(new DataColumn("id", typeof(int)));
			dt.Columns.Add(new DataColumn("display");
			DataRow dr =dt.NewRow();
			dr[0] = 1;
			dr[1] = "Yes";
			dt.Rows.Add(dr);
			dr =dt.NewRow();
			dr[0] = 0;
			dr[1] = "No";
			dt.Rows.Add(dr);
			((GridComboBoxListBoxPart)cr.ListBoxPart).DataSource = dv;
			((GridComboBoxListBoxPart)cr.ListBoxPart).DisplayMember = "display";
			((GridComboBoxListBoxPart)cr.ListBoxPart).ValueMember = "id";
		}
	}
}

Bidin Dinesababu
Replied On August 10, 2004 05:24 PM UTC

Thanks for the quick response. I could make it work with the following code. //Modify stules grid.Model.ColStyles["column5"].CellType = "CheckBox"; grid.Model.ColStyles["column5"].CheckBoxOptions.CheckedValue = "Yes"; this.Model.ColStyles["column5"].CheckBoxOptions.UncheckedValue = "No"; And populating the column values as "Yes" for 1 and "No" for 0.

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

;