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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

CheckBox Column Tristate Indeterminate Value

Thread ID:

Created:

Updated:

Platform:

Replies:

32192 Jul 25,2005 07:38 AM UTC Jul 26,2005 07:24 AM UTC WinForms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On July 25, 2005 07:38 AM UTC

The CheckboxOptions of the GridStyleInfo object has a string datatype for the IndetermValue property. The problem is my bound column (Db Constraint) accepts "Y", "N" and null as valid values. How do I get the grid to push DbNull.Value when the user clicks to the third Indeterminate option? When I use DbNull.Value.ToString() it''s just an empty string (""), so thats what the bound column gets, instead of the desired value of DbNull.

Administrator [Syncfusion]
Replied On July 25, 2005 08:36 AM UTC

You can try handling the grid.Model.SaveCellInfo event, and swap out the value before it gets saved.
private void Model_SaveCellInfo(object sender, GridSaveCellInfoEventArgs e)
{
	if(e.Style.CellType == "CheckBox" 
		&& e.Style.CellValue != null 
		&& e.Style.Text.Length == 0)
	{
		e.Style.CellValue = DBNull.Value;
	}
}

Administrator [Syncfusion]
Replied On July 26, 2005 02:45 AM UTC

Thank-you that works. Is there like an internal reason why the data types of the CheckBoxOptions have to be strings? Perhaps if they were instead of type object, than supplying DbNull.Value or anything else would be an option, instead of attaching to the prescribed event?

Administrator [Syncfusion]
Replied On July 26, 2005 07:24 AM UTC

The checkbox options determined what is displayed in the cell. For example, if CellValueType is bool, then a bool value is stored in the cell, and you set the display values in the check box options to be "true", "false" and "" as that is what will be displayed as text in the cell. Here, a DBNull.Value is stored as the indeterminate value since when the grid converts a "" to a bool it comes up with DBNull. But in your case, you actually are storing strings ("Y", "N") as the cell values so this means the CellValueType must be string. When the grid then tries to convert the indeterminate value "" to string, well it already is a string, so the grid leaves it alone. The grid does not know you want it to change the empty string into a DBNull since the cellvaluetype is string and the empty string is a valid string. So, in your use case, swapping the empty string for DBNull takes the additional work of handling an event. If your cellvaluetype was bool, this would not be needed.

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

;