Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
415
Binding To UltraWinTree
posted

Below is a stripped out version of my object...

public class OffLineFolder
{
private string _offlineFolderFriendlyName;
private string _offlineFolderActualName;
private BindingList<OffLineDBFile> _offlineFileList;
private BindingList<OffLineFolder> _offlineSubFolder;

public string OfflineFolderFriendlyName
{
get
{
return _offlineFolderFriendlyName;
}
set
{
_offlineFolderFriendlyName = value;
OnPropertyChanged("OfflineFolderFriendlyName");
}
}

public string OfflineFolderActualName
{
get
{
return _offlineFolderActualName;
}
set
{
_offlineFolderActualName = value;
OnPropertyChanged("OfflineFolderActualName");
}
}

public BindingList<OffLineDBFile> OfflineFiles
{
get
{
return _offlineFileList;
}
}

public BindingList<OffLineFolder> OfflineSubFolder
{
get
{
return _offlineSubFolder;
}
}
}

What i would like is to have the following structure displayed...

\\mydomain1\myshare1\myfolder1

     subfolderA

     subfolderB

          sub-subfolder1

          sub-subfolder2

     subfolderC

\\mydomain2\myshare2\myfolder2

     subfolderA

     subfolderB

     

So, the OfflineFiles list property would always be hidden. The OfflineFolderFriendlyName would always be the display text.  And i do not want to show a node for the property OfflineSubFolder - just the subfolder items themselves.

I have played around with various options on the treeview but i just cant get it to look how i describe above.  I could get it to show how i want it by creating the nodes manually but ideally i'd like to it through databinding.

Could someone please guide me in the right direction?

Thanks

Danial

Parents
  • 469350
    Offline posted

    Hi Danial,

    There are a couple of ways you could achieve this. How you do it depends on the needs of your application. But there are some issues with your data source that you should work out first.

    I am assuming you are binding the tree to a BindingList<OffLineFolder>. Is that correct?

    The way you have it set up now, OffLineFiles and OfflineSubFolder will initially return null. OfflineFiles doesn't really matter, since you want to hide it anyway, but OffLineSubFolder will be a problem, because the DotNet BindingManager will be unable to determine the data structure if the property returns null. So you should make these properties lazily-created and return an empty collection and never null,

    To hide the OffLineFiles, you have two options. You could put a [Browsable(false)] attribute on the property. This will hide this property from DataBinding in general, as well as from the property grid (which probably doesn't matter).

    The alternative is to hide the column in the tree. Every property on your object will be a column in the ColumnSet that the tree creates to represent your data structure. So you could handle the tree's ColumnSetGenerated and set the Hidden property on the OfflineFiles column. Or even remove the column entirely, if you want.

    OfflineSubFolder is showing a band node because you have two sibling child bands in your data source (OffLineSubFolder and OffLineFiles). Hiding the OffLineFiles should alleviate the need for that extra node. If you hide OffLineFiles on the data source, it shouldn't be a problem. If you hide it in the ColumnSetGenerated event, I think it will still work, but I am not 100% sure - there might be an issue of timing there.

Reply Children