I have a UltraTree with Nodes, where i want a UltraComboEditor beside. My Node now has a Checkbox, a Image and a Text.
Beside the Text should be a ComboEditor.
You can see how the tree should look like in the next picture.
UltraTreeNode node = new UltraTreeNode(); node.Override.NodeStyle = NodeStyle.CheckBox; node.LeftImages.Add(element.Image); node.Text = element.Text;
node.Override.EditorComponent = new MyCustomControl();
Hi,
There are a few different ways you might go about achieving this. But you can't really do it with a single ViewStyle.Standard node.
One hurdle is that a ViewStyle.Standard node doesn't have any way to store a third piece of information. The UltraTreeNode has a CheckState property to store the state of the built-in checkbox and it has a Text property to store the text. But there's no third property to store the value of a ComboEditor. Attaching an UltraComboEditor to the node edits the node's Text.
So the simplest way I can see to get around this would be to make your child nodes show in ViewStyle.Grid. That way you could have a column for the checkbox, one for the image, one for the text and one for the combo. How you do that depends on the structure of your tree, but from the screenshots here, it looks like you have a pretty simple structure with only two levels. So if that's the case and your second level is always going to be child nodes, you could create a ColumnSet and apply it to the tree's NodeLevelOverrides for the second level.
I attached a small sample project here to demonstrate the basics.
WindowsFormsApplication19.zip
Hi Mike,
thanks for the answer. I doing well with your sample but still have some problems and questions.
- how can i hide the border around the grid/columns? I only want checkbox, image, text, combo, with no border around. I tried the following two lines, but with no success.
tree.BorderStyle = UIElementBorderStyle.None;
tree.ShowRootLines = false;
- How can i hide some columns in special rows?
As you can see in the picture, i only want to see the green comboColumn, but hide all red parts of the picture.
- I have problems to display my image in the imageColumn. i use a ImageList and what to set the image with its ImageList Name in the Column.
- The click on the Checkbox is not responding. which event/setting do i need?
Thanks for following up with your progress! Glad we could help. :)
your solution works fine, thats exactly what we want.
thx for your reply.
We want our customers to drop the list down and choose an item, but it shouldn't be possible to type into it.
I'll try your solution and give you feedback.
Greets
Jochen Rosenthaler said:In my ComboBox i see the values of the ValueList properly. But unfortunately I'm able to write something in the combo by myself to an existing entry. I use comboColumn.AllowCellEdit = AllowCellEdit.Full; - if i use comboColumn.AllowCellEdit = AllowCellEdit.ReadOnly; - than i can not dropdown the comboBox and choose different values.
Just to clarify... what exactly do you want here? Are you saying you want the user to be able to drop down the list and see it, but not choose an item? Or are you saying they can choose an item from the list, but you don't want them to be able to type into the cell?I'm not sure if the former is possible, but I believe the latter is. The wasiest way is to create an UltraComboEditor control and set it to DropDownList and apply it to the column. It sounds like you are already doing that, anyway.
if (includeComboColumn) { var comboColumn = columnSet.Columns.Add("Combo"); comboColumn.DataType = typeof(int); UltraComboEditor ultraComboEditor = new UltraComboEditor(); ultraComboEditor.DropDownStyle = DropDownStyle.DropDownList; this.Controls.Add(ultraComboEditor); comboColumn.EditorComponent = ultraComboEditor; var valueList = new ValueList(); valueList.ValueListItems.Add(0, "Apple"); valueList.ValueListItems.Add(1, "Banana"); valueList.ValueListItems.Add(2, "Cherry"); valueList.ValueListItems.Add(3, "Grape"); valueList.ValueListItems.Add(4, "Watermelon"); comboColumn.ValueList = valueList; comboColumn.AllowCellEdit = AllowCellEdit.Full; }
Having a read-only combo while wanting to still be able to dropdown is not possible and considered to be a new product idea.
You should be able to modify the border using the combo's Appearance property.
Themes might be enabled. Theming is all-or-nothing. So if Themes are on, then whole control is drawn themed and you can't change any individual colors of any of the themed elements.
So you probably have to set UseOsThemes on the control to false in order to change the border
eg.
comboEditor.Appearance.BorderColor = Color.Red