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
335
Can I display a checkbox as a radiobutton?
posted

Hello !

I'm using an UltraGrid and have as DataSource a DataSet. Every Row has two checkboxes and only one can be activated at a time.

 

I'm doing this by using the following Method:

 

private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)

{
  if (e.Cell.Column.Key == "Datapacket" || e.Cell.Column.Key == "Database")
     {
          bool temp = (bool)e.Cell.Row.Cells["Database"].Value;
          e.Cell.Row.Cells["Database"].Value = e.Cell.Row.Cells["Datapacket"].Value;
          e.Cell.Row.Cells["Datapacket"].Value = temp;
     }
}

 

Now I need to have those checkboxes displayed as radiobuttons. Does anyone has an idea for this?

I read something about OptionSets but if I understood right, this is for mutual exclusion in more than one rows and not within one row.

 

Thank you for any answers,

Renelope

  • 469350
    Offline posted

    Hi Renelope,

    You will need to use an UltraCheckEditor control for this, and assign it as the EditorComponent of the grid columns. Then you can change the glyphs via the GlyphInfo property on the UltraCheckEditor. You could create your own glyphs if you like, and that would allow you to change the appearance of every state/value combination of the CheckBox. But a quicker way to do it would be to simply assign one of the radio button glyph sets to the CheckEditor.


            private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {
                // Create a new UltraCheckEditor control
                UltraCheckEditor ultraCheckEditor = new UltraCheckEditor();

                // Set the GlyphInfo to the radio button glyphs using either Office2007 or the
                // standard  radio button glyphs.
                //ultraCheckEditor.GlyphInfo = UIElementDrawParams.Office2007RadioButtonGlyphInfo;
                ultraCheckEditor.GlyphInfo = UIElementDrawParams.StandardRadioButtonGlyphInfo;

                // Align the checkbox in the center.
                ultraCheckEditor.CheckAlign = ContentAlignment.MiddleCenter;

                // Add the control to the Controls collection of the form. This is not really
                // neccessary in order to change the glyphs, but it ensures that the UltraCheckEditor
                // control gets disposed along with the form.
                this.Controls.Add(ultraCheckEditor);

                // Assign the check editor to the columns that should display checkboxes as
                // radio buttons.
                e.Layout.Bands[0].Columns["Boolean 1"].EditorComponent = ultraCheckEditor;
                e.Layout.Bands[0].Columns["Boolean 2"].EditorComponent = ultraCheckEditor;
            }