Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't enable ComboBox

I have a ComboBox which I am placing in a SourceGrid3 control, but for some reason I can't set the Enabled attribute to true.

Here is my code.

ComboBox cboMyComboBox = new ComboBox(); 
cboMyComboBox.Enabled = true;
cboMyComboBox.BeginUpdate(); 
cboMyComboBox.Items.AddRange(new object[] { "Accept", "Reject" });
cboMyComboBox.EndUpdate();
cboMyComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
SourceGrid3.Cells.Real.CellControl thisControl = new SourceGrid3.Cells.Real.CellControl(cboMyComboBox);

myGrid[row, column] = thisControl;

(myGrid is the SourceGrid3 grid)

For some reason when the last line gets executed, the Enabled value gets turned to false and subsequent attempts to change it (like setting it back to true) don't have any effect.

Even if I try and change the value to true in the Visual Studio debugger, it won't allow it and simply changes it back to false. I have looked for a ReadOnly attribute for this field but there doesn't seem to be one (unless I'm missing something) besides I can change other attributes (like RightToLeft from No to Yes)

Is there anything else I can check that might cause this control to be forced to false ?

like image 267
colmde Avatar asked Jul 31 '26 21:07

colmde


1 Answers

The Problem:

If a general Property which exists in all UI-Elements is set for a Control it will pass its value down to all child elements.

Speaking generally this will overwrite the Value of this property for all child controls.

The Solution:

Set the Enabled-Property for your Grid to true and leave it unassigned in your ComboBox or just remove the Enabled=false in your grids definition.

like image 118
Felix D. Avatar answered Aug 02 '26 11:08

Felix D.