Hi ,
I have a comboBox that has three options i.e TextBox , ComboxBox , UltraComboEditor ( with check boxes). Depending on what the user clicks , that control should be displayed ontop of a Panel in a Table Layout Panel. I am achieving this using if else and setting Visible property to true for one of them and false for the other two.
The text box and combobox get displayed when i choose the respective option but UltraComboEditor doesnt get displayed . Initiailly I keep all of their visibily to false . Then I go changing based on user selection.
My problem is that my UltraComboEditor never seems to be displayed. Heres some code :
private void Form1_Load(object sender, EventArgs e) {
this.ultraComboEditor1.CheckedListSettings.CheckBoxStyle = Infragistics.Win.CheckStyle.CheckBox; this.ultraComboEditor1.CheckedListSettings.CheckBoxAlignment = ContentAlignment.MiddleLeft;
}
private void comboBox3_SelectionChangeCommitted(object sender, EventArgs e) { ReplaceComponent((ComboBox) sender, comboBox8, textBox3,ultraComboEditor3);
private void ReplaceComponent(ComboBox sender,ComboBox c,TextBox t,UltraComboEditor u) { if (sender.SelectedItem.ToString() == "ComboBox") { c.Items.Clear(); c.Items.Add(""); c.Items.Add("ASA"); c.Visible = true; t.Visible = false; u.Visible = false; } else if (sender.SelectedItem.ToString() == "UltraComboEditor") { u.Items.Clear(); u.Items.Add("Black Oil"); u.Items.Add("Dry Gas"); u.Items.Add("Gas Cond"); u.Items.Add("Heavy Oil"); u.Items.Add("Volatile Oil");
u.Visible = true;
t.Visible = false; receiver.Visible = false; } else if (sender.SelectedItem.ToString() == "TextBox") {
u.Visible = false;
t.Visible = true;receiver.Visible = false;
Only other way i can do this is by passing the panel and clearing all contorls and adding the one I want .
Hello Prasaanth,
I am just checking about the progress of this issue. Let me know if you need my further assistance on this issue.
Thank you for using Infragistics Components.
Thank you for the reply.
What I believe the issue is in this case is the control is never added to the panel’s (or the form’s) control collection. So when you are initializing the UltraComboEditor, please add the following line, which should resolve the issue (and make sure it isn’t removed in a later point):
panel.Controls.Add(u);
This will add the control to the panel and then when you set Visible to true it should be displayed. If that doesn’t fix this issue, please provide me with a small project that reproduces it.
As for how to get the checked items as a list of strings, you can use the CheckedItems property of the UltraComboEditor. You can achieve this goal with the following line:
List<string> checkedItems = ultraComboEditor1.CheckedItems.Select(i => i.DisplayText).ToList();
Please let me know if you have any additional questions.
right now am iterating and adding the items cast to list. is there a better way
also i would like to know how to get all the checked items in an ultracomboeditor as a list of strings.
Sorry ,
I wished to say Hi Dimitar. :)