Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with column resizing when made active

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
taurin



Joined: 03 Jan 2008
Posts: 7

PostPosted: Fri Aug 14, 2009 6:22 pm    Post subject: Problem with column resizing when made active Reply with quote

Hi, I have 3 columns in my tree (A, B, and C). A always shows, but only one of the others shows at any given time. I have AutoFitColumns set to True.
Usually when I hide a column and show the other, they will show as the same size (which is what I want). However, if I auto-size the first column (by double clicking on the separator) and then hide/show the columns, the sizes will not stay the same (they will be different depending on which column is showing). I have tried storing the width of the columns before hiding and showing and then setting it afterward, but it ignores this change.
Is there anything I can do without losing the benefits of AutoFitColumns?


Last edited by taurin on Tue Aug 18, 2009 9:13 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Sat Aug 15, 2009 1:06 am    Post subject: Reply with quote

Thanks for posting the sample project - that certainly makes it easier to see what the issue is. Your tree has AutoFitColumns set to true which means that it will resize the columns to make them fit the available width for the tree control. It uses the Column.AutoFitWeight property to determine the relative proportion of the total width to assign to each column. The AutoFitWeight property is set by default to 1 for each column - which means that the columns are all of equal width. When the user resizes a column the AutoFitWeight is recalculated for each column so that if you resize the total control width the same proportions are maintained. So what is happening in your sample is that the AutoFitWeights of the active columns have been updated when the user resizes the first column - however the inactive column still has the original value of 1 for AutoFitWeight. When you make it active it therefore changes the layout. The solution is to set the AutoFitWeight of the column you are making active to the value of the now inactive column. Here is the code:

Code:
private void ShowColumns()
{
    virtualTree1.SuspendLayout();
    try
    {
        colFieldTwoData.Active = chkShowData.Checked;
        colFieldTwoName.Active = !chkShowData.Checked;
        if (colFieldTwoData.Active)
        {
            colFieldTwoData.AutoFitWeight = colFieldTwoName.AutoFitWeight;
        }
        else
        {
            colFieldTwoName.AutoFitWeight = colFieldTwoData.AutoFitWeight;
        }
    }
    finally
    {
        virtualTree1.ResumeLayout();
    }
}

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
taurin



Joined: 03 Jan 2008
Posts: 7

PostPosted: Mon Aug 17, 2009 2:44 pm    Post subject: Reply with quote

Worked like a charm, thanks for the help.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group