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.
You could use TooltippText to present your item-code and your item-text to be in the display text or other way is to use formatted text like String.Format(“item-text: {0, 10}; item-code:{1, 10}”, item-text, item-code) for text of UltraListView items in order to simulate two columns.You could use code like:
for(int i=0; i < 10; i++) { UltraListViewItem item = new UltraListViewItem(string.Format("{0,10} {1,10} ", i, i),null,null); ultraListView1.Items.Add(item); }
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
Markus
Hello Hristo,
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?
Regards
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.
probably I have found the problem. If I set the width to a fixed size for c1Size it looks nice:
Size c1Size = new Size( 95, editor.Rect.Height );
I can determine the longest text for "column 1" from my domain and measure the string size using draw utility and set the size to this value.
Graphics graphics = DrawUtility.GetCachedGraphics( this.ListView1 );
try {
string refMaxString = new String( 'D', this.maxDomainLen + 1 ) );
this.maxWidth = (int)graphics.MeasureString( refMaxString, this.ListView1.Font ).Width;
finally {
DrawUtility.ReleaseCachedGraphics( graphics );
I will try to use this in my project. Thanks for the idea.
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?