Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
440
Two State Checkbox showing up as tri state
posted

Hi,

I am creating my columns dynamically in the grid InitializeLayout event. For certain boolean columns, I set their style to Checkbox as I want a two state check box and not the tri state one.

In our application, data imports can insert NULL values in the database. Due to the nature of the application, modifying the existing database structure i.e. setting default values in the database, isn't an option. 

Why does a two sate checkbox show up as tri-state when the value is null. How can I default a null value to false?

  • 469350
    Verified Answer
    Offline posted

    Hi,

    The CheckBox will interpret the data you give it, regardless of the Style. the TriStateCheckbox Style doesn't affect how the data is displayed, it controls how the value is toggled by the user.

    Anyway, to achieve what you want here, you could use a DataFilter. I attached a small sample here demonstrating how to do it. I assume it doesn't matter to you if the data gets changed from null to false, since you are not distinguishing between the two. I am pretty sure that if the user changes the value of a cell and the row gets written back to the data source, the null would be lost and replaced with false. 

    WindowsFormsApplication19.zip