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); }
I'm still not satisfied with my solution using the windows forms listbox control. I should display also images for the items and I don't like these owner draw overhead. Tooltips, like you suggest as solutions, seems not to be a solutions to me (users just see tooltips when mouse over the itme).
If list view control is in ListViewStyle = List I can display a text right of the image. Is there a way to format these text using tabs at a well defined position (like the old list box control)?
If this is not possible, do you know if your ListViewControl will provide full Listbox functionality in the future?
Regards
Markus
Could you please post a picture of the desired look, which you want to achieve with UltraListView.
I am waiting for your details.
see the attached picture. This is a Windows Form List Box control in multicolumn mode using tabulator formatted text.
The Tab control selects the object category depending on that, I update the binding source filter. If the tab "All" is selected all objects are showed and I like to have images for the different types (labeled as Dienste and Abwesenheiten).
Many years ago, (before ListView exists) with owner draw modus of the listbox you can achieve this. But nowadays I expect some improvement. I mean having the nicer look of the ListView, Images, Text, etc.
What I'm missing with the ListViewControl ist that the text can not be formatted that it looks like the picture (object code AD_1 and Object description aligned at the first tabulator position).
I hope I could explain my needs and you have a solution for me.
I have created a small sample in order to see the difference between Microsoft ListView and UltraListView, please see attached sample. For creating ListView with Multicolumn, I was using the following tutorial from MSDN:
http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.multicolumn.aspx
With UltraListBar, you are able to achieve the functionality shown on your screenshot and also to have an image in front of the item, you are able to define image size and etc. . Please let me know if this is what you are looking for.
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
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?
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?