I'm having a problem with the UltraCombo control.
when the form loads we set every control on the form readonly (if that control is capable). There is a button on the form that clears the readonly. So far everything works correctly.
Now when I set the cursor in the UltraCombo control (for selecting the readonly text) and I press the button to clear the readonly, then the ultracombo control stays in readonly.
Is this a bug or do I have to do something with the control before making it writable again?
That sounds like a bug...what you might be able to do to work around it is force the editor out of edit mode after changing the value, then go back into edit mode. You can do that by setting some other control on the form to be the ActiveControl, then set it back to the UltraCombo control.
doesn't work. The control stays in readonly mode
Sebastian,
I tried this with our latest version and the control is behaving as expected. I'd like for you to please modify my sample attached so that it reproduces the behavior for us to look into further. When the control is set to ReadOnly, clicking the button will make the control editable and focus should be taken to the button.
Let me know if you have any questions regarding this matter.
I see now what the developer did. He made a generic method to make all the controls on the form readonly.
I edited the sample to do what happens with us. And the combo won't get out of readonly.
The problem lies with the way we set the controls readonly. Because the child controls in the combo are also set readonly, and problem lies with that I guess.
The reason why we check if the control has children is because sometimes controls are placed inside a panel en that panel is placed inside another....
but thanks for the help
private void SetReadOnlyControl(Control control, bool readOnly){ if (control.HasChildren) { foreach (Control c in control.Controls) SetReadOnlyControl(c, readOnly); } else { if (control.GetType().GetProperty("ReadOnly") != null) control.GetType().GetProperty("ReadOnly").SetValue(control, readOnly, null); else if (control.GetType().GetProperty("Enabled") != null) control.GetType().GetProperty("Enabled").SetValue(control, !readOnly, null); }}
That did the trick :D
Thanks for all the help!!!
Hi Sebastian,
The sample reproduced the behavior at first, and I was able to modify it so that the UltraCombo becomes editable again. I had to make two small changes.
First, I commented out the "else" in SetReadOnlyControl. Currently, the logic in SetReadOnlyControl either sets the ReadOnly flag on a control or its children. Removing the else causes the method to set the ReadOnly flag on the control's children and then itself. Note that I literally only commented out the "else" -- I left the rest of the condition intact. The code now looks like this:
private void SetReadOnlyControl(Control control, bool readOnly){ if (control.HasChildren) { foreach (Control c in control.Controls) SetReadOnlyControl(c, readOnly); } //else { if (control.GetType().GetProperty("ReadOnly") != null) control.GetType().GetProperty("ReadOnly").SetValue(control, readOnly, null); else if (control.GetType().GetProperty("Enabled") != null) control.GetType().GetProperty("Enabled").SetValue(control, !readOnly, null); }}
Next, I swapped the order of the lines in the ultraButton1_Click event handler. The first time the click handler runs, it was setting the combo to readonly again. Subsequent clicks toggled the readonly state as intended. The code now looks like this:
private void ultraButton1_Click(object sender, EventArgs e){ _readonly = !_readonly; SetReadOnlyControl(ultraCombo1, _readonly);}
Please make these changes to your code and let us know if it works.