Is NTreeList BestFit asynchronous?


Author
Message
Craig Swearingen
Craig Swearingen
Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)
Group: Forum Members
Posts: 99, Visits: 654
Using build 15.11.12.12 on Win7.  I'd like to use the NTreeList BestFit or BestFitAllColumns method to change my column widths based on the data in the NTreeList.  However, for a few columns I don't want their width to be greater than 200.  I'm calling:

myTree.BestFitAllColumns();
if (myTree.Columns["largetextcol"].Width > 200)
    myTree.Columns["largetextcol"].Width = 200;

The setting of 200 doesn't work.  The BestFitAllColumns width is used instead.  If I change it like this:

myTree.BestFitAllColumns();
myTree.Update();
if (myTree.Columns["largetextcol"].Width > 200)
    myTree.Columns["largetextcol"].Width = 200;


This works.  Unless my NTreeList is not visible.  In my case my NTreeList may be on a tab of a NTabControl that is not visible.  I've tried some other methods on the NTreeList widget but nothing seems to help.  How can I get the BestFitAllColumns algorithm to run such that I can then set my max column widths?

Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hello Craig,

You can try to change the column width when some of the column's property has changed by attaching to NTreeList.ColumnNotify event as follows:


myTree.ColumnNotify += nTreeList1_ColumnNotify;

...

void nTreeList1_ColumnNotify(object sender, NTreeListColumnNotifyData data)
{
    NTreeListColumn column = nTreeList1.Columns["largetextcol"];
    column.Header.Text = column.Width.ToString();

    if (data.Column == column
        && data.NotifyCode == NTreeList.ColumnPropertyChangedNotifyCode
        && column.Width > 200)
    {
        column.Width = 200;
    }
}


This way when the control becomes visible the event handler for ColumnNotify should be called and the column resized.

I hope this helps.


Best Regards,
Nevron Support Team


Craig Swearingen
Craig Swearingen
Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)
Group: Forum Members
Posts: 99, Visits: 654
Thanks for the tip.  I was wondering if I would need to approach it similarly but I was hoping I was just missing something that was available to do synchronously.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search