I'm loocking for the best control for a pick list of items. One item has two attributes (item-code, item-text). I can do it with a multi column listbox of the standard windows forms control.
To have a nicer look (headers, images), I tried the UltraListView control. If users resizes the control the columns should be rearranged to avoid scrollbars as possible (like multicolumn listbox). The ListView control shows this behavior in view type "list", but not in "detailed".
How setup the ListView control for my needs? If not possible, any suggestions for another control?
Thanks for your help.
Regards. Markus
Hello ,
When UltraListView is in Details view, actually it display a grid with at least one Main column (unique for the grid) and other columns, which could be used to represent a different information, depends on the custom customer needs. That is why when UltraListView is in Details view , the component shouldn’t rearrange its items in more than one main columns. As you said UltraListView cover your requirements when it is in List view mode, why you want then to use it in Details mode, maybe I am missing something from your scenario?
Please let me know if you have any further questions.
Hello,
I have to display at least two properties of my items: one column for the item-code, one column for the item-text. Thats the reason I'm using Details mode.
For that, I'm looking what solutions I have to solve these requirements. One solution is the Windows Forms listbox in multi column mode. The ListView Control can have headers and images and looks nicer. This is why I'm try to configure the ListView control to achieve the same behaviour.
If ListView Details mode can not be configured as needed, you mybe has any other suggestions? There are lots of controls with lots of capabilities and, maybe, I'm missing something.
The behavior which you are facing is caused by the fact that the font which you are using has a different with for the different characters. You could create a class, which will represent your two-column item and also to make own implementation of CreationFilter interface, in order to display a different text editor for each “column”. I have implemented my idea in a small sample. Please run the sample and move slider of “First Column Width %” track bar, in order to adjust the width of the first column, then move slider of “Define UltraListView Column Width” track bar, in order to apply the changes.
Hello Hristo,
thank you for the sample. Interesting idea. I have looked at it now. It seems that the problem still resides (see printscreen of your sample). In the picture you see that the second "column" is not at the same position for Item 9 and Item 10.
I have not figured all details of your solution. You said it's just a idea. Maybe I can play around a little bit. If it is possible to define two controls and their sizes, I guess it must be possible to define it the same size for all items. I don't know?
Do you have a suggestion to improve the sample?
Regards
Markus
This little difference caused by the fact that we should get width of the UltraListViewItemEditorAreaUIElement in order to calculate correctly locations and widths of the EditorWithTextDisplayTextUIElement which you are using to display two columns. So you could fix this if you change the code in MyCreation class AfterCreateChildElements method as followed:
EditorWithTextUIElement editor = parent as EditorWithTextUIElement;
if (editor != null && editor.HasChildElements)
{
TwoColumnItemString value = ((Infragistics.Win.UltraWinListView.UltraListViewMainItemTextAreaUIElement)(editor.Parent)).Item.Value as TwoColumnItemString;
if (value != null)
editor.ChildElements.Clear();
EditorWithTextDisplayTextUIElement c1 = new EditorWithTextDisplayTextUIElement(editor, value.FColumn);
EditorWithTextDisplayTextUIElement c2 = new EditorWithTextDisplayTextUIElement(editor, value.SColumn);
Size c1Size = new Size((int)(TwoColumnItemString.FColWidthPercent * editor.Parent.Parent .Rect.Width), editor.Rect.Height);
Size c2Size = new Size(editor.Parent.Parent .Rect.Width - c1Size.Width, editor.Rect.Height);
c1.Rect = new Rectangle(editor.Rect.Location, c1Size );
c2.Rect = new Rectangle(new Point(editor.Rect.Location.X + c1Size .Width,editor.Rect.Location.Y)
, c2Size );
editor.ChildElements.Add(c1);
editor.ChildElements.Add(c2);
}
Please feel free to modify the sample base on your needs.
thank you for your solution. Your sample works with correct aligned "columns" but with the selection of a item is something wrong (see attached pic). The second "column" is somewhat truncated. The amount of truncation depends on the width scrollbar settings.
Do you know why this happens?
Hello again,
I can not setup the editor sizes and column width properly. In your sample there are combinations of first column width % and UltraListView column width everything looks fine. But if you increase the values the item text gets truncated by the selection rectangel.
I could not figure out how are the selection rectangle is calculated or how I can configure this?
I calculate the maxWidth of firstColumn and secondColumn using draw utility and use this values to specify c1Size and c2Size in the creation filter:
Size c1Size = new Size( this.maxFirstColumnWidth, editor.Rect.Height );Size c2Size = new Size( editor.Parent.Parent.Rect.Width - c1Size.Width, editor.Rect.Height );
Once I set the UltraListViev.ViewSettingsList.ColumnWidth = maxFirstColumnWidth + maxSecColumnWidth).
But this does not help. Item Text is still truncated if selected even if the sizes of the two EditorWithTextDisplayTextUIElement not exceed the parent editor.
Can you give me some more advises?
Thank you