Hi,
I have a grid where the first 3 columns are fixed since they contain images. If I grab the column handle on any other column and resize the column, it seems to randomly add/subtract the width from another column, sometimes it's the column before the one I resized, sometimes it's the one after, etc. I would expect that if I resize the fourth column, for example, the columns after the resized column would be the only one(s) affected. I'm using NetAdvantage 10.2 build 2151. Is there some setting I need to set or some way to make the resizing more predictable?
thanks
Mario
Hi Mario,
mpiccoli said:I have a grid where the first 3 columns are fixed since they contain images.
What do you mean by "fixed"? It sounds like you mean that the columns width cannot be changed- but that's not really what fixed means. Fixed means that the column doesn't scroll. So I just want to make sure I understand.
Either way, how exactly are you going about "fixing" the column. If you don't want the columns width to change, I recommend setting both the MinWidth and MaxWidth of the column to the same value, and also setting the Locked property on the column to true.
Also... the only case where sizing one columns affects another column is if you have set the AutoFitStyle property. So what are you setting it to?
Hi Mike,
Sorry, bad choice of words. I'm setting the MinWidth, MaxWidth, and LockedWidth of the first 3 columns so that the width remains constant. The AutoFitStyle property is set to ResizeAllColumns.
If you are setting all of those properties and the columns are still changing width, then something is wrong.
What version of the controls are you using?
Are you setting RowLayoutStyle (or UseRowLayouts)?
Can you post a small sample project demonstrating the issue?
The first 3 columns are not changing width at all, the rest of them are. I'm using NetAdvantage 10.2 build 2151. I am not setting RowLayoutStyle at all. I have enclosed a sample project. Most of the grid settings are in the UiHelper class. The app is similar to outlook where the first 3 columns are image columns. I have no issues with those columns. The From, Subject, Received and Size columns are where the issue occurs. If I grab and resize the Received column, for instance, The From or Subject columns may change width. When the grid is initially shown, I would like the Subject field to get most of the width - the Received and Size columns get autoresized to AllRowsInBand via the PerformAutoResize method. Once the user grabs the column resize handle I would expect the columns after to resize, but it seems to be randomly picking the non-image columns to change widths. This may be due to the fact that I'm setting the AutoFitStyle to ResizeAllColumns.
I realized last night that the sample I gave you relies on a couple dlls that are probably not part of that zip file. So I'm attaching a modified version.
Okay, I think I misunderstood your initial description of the issue. I thought you were saying that the locked columns were getting resized.
I tried your sample and it doesn't seem random to me.the grid seems to be behaving very consistently.
When you make a column smaller, what the grid is doing is taking the amount of width that has been long and evenly dividing it between the remaining, sizeable columns. So all of the columns get bigger by the same amount.
There's no property in the grid to change this behavior. You might be able to get he behavior you want by handling the BeforeColPosChanged event. This is the event that fires whenever you resize a column. The event args gives you the new sizes and you can compare these to the current sizes of the columns and then modify them however you like. I haven't tried this, but I think it should work.
Another option might be to use a RowLayout. RowLayouts allow you to assign a weight to each column which is used when re-distributing logical width in the layout.
When I resize the Subject or Received column, for example, I wasn't expecting the From column to change (which is the column prior to those columns) - I was only expecting the columns after the resized column to change. This is the behavior in Microsoft Outlook when resizing - it only affects the columns after the one being resized. I will look into the other two options you mentioned to see if I can get the behavior I'm looking for unless you have other suggestions based on my comments here.
I did try setting AutoFitStyle on the grid to be ExtendLastColumn, but then there are other issues that arise when doing that, one of them being that I would now have to figure out at what width to set the columns before the last one initially.