Hi,
I am adding a CheckBox column to my wingrid at runtime. How can I make it default to 'false' as opposed to the filled in square of 'null'? Right now I am looping through each cell and setting it to False. This is also marking the row as "edited". Does anyone know a better way? Here is my code so far:
Infragistics.Win.UltraWinGrid.UltraGridColumn completedColumn;
completedColumn.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;
{
}
Looping through the rows is certainly not the best way to do it.
The best way is probably to do it on the data source. What kind of data source are you using? Most data sources, like a DataTable or UltraDataSource let you specify a default value for a column.
Another way to do it would be to use the InitializeRow event of the grid, rather than looping.
I am just googling on Default value for CheckBox Column and found this post .
If I apply the same thing on InitializeRow event then It will fire the AfterRowUpdate, AfterCellUpdate and Other event.
I want the same thing without fire the AfterRowUpdate, AfterCellUpdate and other event on InitializeRow event.
Kindly suggest.
Vijay
Hi Mike,
I want checkbox is check by default when ultragrid is loaded can we do setting in properties?
I've never used the datafilter before, works great.
Implementation was a breeze thanks to your sample!
I whipped up a quick sample to show you how the DataFilter approach would work. Let me know if you have any questions.
Indeed, I'd like to display both false and dbnull as unchecked.
I'll have a look at the datafilter. The grid is only used to display the values, no editting allowed.
What, exactly, is the issue you are having?
The CheckBox in the cell reflects the value of the cell. So the way to "fix" this is to have the value of the cell (and therefore the value of the data source) return a valid value.
If your cell contains a null or DBNull, then that is not a valid true/false value. If you want the CheckBox to treat a null value as unchecked (as opposed to indeterminate), then you could use a DataFilter that converts null to false and vice versa. Is that what you want? If you do that, then the value of false will always be null in the data source. There's no way for a data filter to determine that the cell was originally null, but got translated to false by the datafilter. So either the cell would change the null to a false the first time it updated, or else you would always have to use null for false, instead of actually using false.