I know i read a post about using a BindingList for Custom Class for UltraTree and so far it works.
Here's my code
public class ScreenViewList : BindingList<ScreenClass> { } public class ScreenClass { private BindingList<ScreenObjectClass> _screenobjects = new BindingList<ScreenObjectClass>(); public int ScreenID { get; set; } public string ScreenName { get; set; } public Image PrivilegeLevel { get; set; } public BindingList<ScreenObjectClass> _Screenobjects { get { return _screenobjects; } set { _screenobjects = value; } } } public class ScreenObjectClass { private string _name; private int _scrID; private int _objID; public ScreenObjectClass(int ScrID, int ScrObjID, string Name) { _name = Name; _objID = ScrObjID; _scrID = ScrID; } public int ScreenObjectID { get { return _objID; } set { _objID = value; } } public int ScreenID { get { return _scrID; } set { _scrID = value; } } public string ObjectName { get { return _name; } set { _name = value; } } }
the property with Bold in ScreenClass, I want to Display as Image on TreeView but unable to display Image.
On the Form I do this by getting the data from the database.
ScreenViewList _screenviews = new ScreenViewList(); foreach (DataRow rowscreen in ds.Tables[0].Rows) { ScreenClass _screen = new ScreenClass(); _screen.ScreenName = rowscreen["ScreenName"].ToString(); _screen.ScreenID = Convert.ToInt32(rowscreen["ScreenID"]) ; _screen.PrivilegeLevel = Imagelist1.Images[0]; _screenviews.Add(_screen); this.LoadScreenObjects(Convert.ToInt32(rowscreen["ScreenID"]),_screen); } tv.BeginUpdate(); BindingSource bg = new BindingSource(); bg.DataSource = _screenviews; tv.DataSource = bg; tv.EndUpdate(); I see the PrivilegeLevel Column with values as System.Drawing. Can someone please correct me what i am doing wrong here.
Thanks
I think i was able to figure out a way for Column Header width setting it manually by using
e.ColumnSet.Columns[1].LayoutInfo.PreferredLabelSize = new Size(ultratreeview1.Width,0);
on ColumnSetGenerated Event.
Still question 1 and images for each row remains open...
Thanks for the reply. But I was able to get the image for the Header by using your method and my way on the ColumnSetGenerated Event.
e.ColumnSet.Columns[2].Control.Nodes.Override.NodeAppearance.Image = imageList1.Images[0];
But my question was for each record.
Anyway, let me ask another set of questions
1. Instead of using an Image i thought of using a Integer value (thats what stored in the database. So, my question is
it displays one the 3 values (0,1 or 2) so instead of showing numbers i would like to show a dropdown for that column where use can pick one from the list.
2. The Cell Header width looks like its fixed how i do i change it. I tried everthing from AutoSizeColumns and nothing seems to work.
It looks like this.
| Screen | Level | ||--> the end of the treeview width
| ID | Name|
Instead i would like it this way
| Screen | Level ||--> the end of the treeview width
-- | ID | Name ||
3. When using Outlook Express Style I am unable to show certain columns (The column Header width automatically resizes to the size of the Treeview here strange)
Top Level
I would like it to see this.
| Screen ||
|ID | Name
I cannot get the Name Field to display if the Top level does not have the second column shown. How do I get the data to display one column for Top level and 2 or 3 columns for the Child node.
If you want the column to display as a picture, then I think what you need to do is use an editor. Place an UltraPictureBox control on the form. Then in the ColumnSetGenerated event, set the EditorControl property of the column to the UltraPictureBox.