Profile Picture

Is NTreeList BestFit asynchronous?

Posted By Craig Swearingen 2 Years Ago
Author
Message
Craig Swearingen
Question Posted 2 Years Ago
View Quick Profile
Supreme Being

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
Last Active: 9 Months Ago
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 Team
Posted 2 Years Ago
View Quick Profile
Supreme Being

Supreme Being (3,273 reputation)Supreme Being (3,273 reputation)Supreme Being (3,273 reputation)Supreme Being (3,273 reputation)Supreme Being (3,273 reputation)Supreme Being (3,273 reputation)Supreme Being (3,273 reputation)Supreme Being (3,273 reputation)Supreme Being (3,273 reputation)

Group: Moderators
Last Active: 2 days ago @ 8:33 AM
Posts: 2,593, Visits: 2,279
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
Posted 2 Years Ago
View Quick Profile
Supreme Being

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
Last Active: 9 Months Ago
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.



Similar Topics


Reading This Topic