ComponentOne True DBGrid for WinForms
Data Presentation Techniques / Automatic Data Translation with ValueItems / Displaying Allowable Values as Radio Buttons
In This Topic
    Displaying Allowable Values as Radio Buttons
    In This Topic

    If the number of allowable values for a column is relatively small, consider a radio button presentation. At design time, go to the C1TrueDBGrid Designer, then to the ValueItems node for the column and set the Presentation property to PresentationEnum.RadioButton. Or, in code:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Me.C1TrueDBGrid1.Columns("Country").ValueItems.Presentation = PresentationEnum.RadioButton
    

    To write code in C#

    C#
    Copy Code
    this.c1TrueDBGrid1.Columns["Country"].ValueItems.Presentation = PresentationEnum.RadioButton;
    

    If necessary, adjust the Width property of the column style and the RowHeight property of the grid to accommodate all of the items.


    For a given cell, if the underlying data does not match any of the available values, none of the radio buttons will be selected for that cell. However, a default ValueItem object can be provided that will be selected instead.

    In this example, the last ValueItem has an empty Value property, but the DisplayValue is set to Other. This means that when Country fields that do not match any of the items are displayed their value in the grid will be displayed as Other.

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Me.C1TrueDBGrid1.Columns("Country").ValueItems.DefaultItem = 5
    

    To write code in C#

    C#
    Copy Code
    this.c1TrueDBGrid1.Columns["Country"].ValueItems.DefaultItem = 5;
    

    In this example, 5 is the zero-based index of the default item.

    See Also