I need to merge two column headers that are side-by-side into a single column header. How do I do that? I'd like the columns themselves to remain separate. I just want the header to look like a single header.
Ahhh, okay, I see it now. I misunderstood what you wrote.
"When we move any other column(except the 2 columns whose headers we are merging) to left of 1st column(whose header is removed and 2nd header is extended), then extended header further increases its width to include other moved column header as well."
I thought you meant drag a column and drop it in front of the merged column. But you mean drag a column that is already in front of the merged column and drop it into a position after the merged column.
The problem here is that the grid determines where to place the dropped column using the UIElements, and the UIElement in this case is the UIElement for Column 1. In fact, it depends exactly where you place the mouse. If you drop when the mouse pointer is over Column 3, then it works fine, because the column is placed before Column 3. If the mouse is over the header for Column 1, then it breaks because you are dropping after Column 1 (in between Column 1 and Column 2).
When I posted this CreationFilter, I never really intended it to work with column moving. These columns appear stuck together, but they are not really joined in any way, so the grid cannot keep them together when moving columns around.
I think I was correct in my previous reply - if you want to be able to suppose column moving, then you will need to handle the BeforeColPosChanged and/or AfterColPosChanged event and fix-up any problems that may occur because the two joined columns got separated. This is not trivial undertaking because you will have to deal with all sorts of cases.
Dropping after Column 1 is one case.
Moving Column 1 itself is another.
And the user can drag more than one column at a time.
Hi,
PFA video to reproduce the scenario.
I'm still not seeing anything wrong here. Here's what I did:
1) Run the sample.
2) Click on the column header for Column 3 to select the column.
3) Click and drag the column header for Column 3 and drop it before Column1.
I then see Column 0, Column 3, Column 1 (which is still the width of 2 columns), Column 4, etc.
Are you seeing something else?
I don't see how ColSwapping being on could possibly have any effect here, but I also tried swapping Column 3 with Column 1 and it still works just fine for me.
I do see a problem if you swap Column 3 with Column 2. Is that what you are doing? Clearly, this would not make sense, because this means you end up moving Column 2 so it is no longer next to Column 1. But that's not what you described here.
Using ColSwapping in this kind of scenario is probably a bad idea. But if you must have ColSwapping, the only thing I can think of is that you could handle the BeforeColPosChanged event and cancel any operation that results in Column 2 no longer being next to Column 1. This is probably not a bad idea to do anyway, just in case.
Hi Mike,
Same behviour can also be checked without enabling column swapping(Please check with sample attached in last post). Just try to move columns to the left of mergerd columns.
I have modified the sample you have provided to re-produce the problem. I have just enabled column swapping feature of grid. Try to move any other column to the left of merged columns. You will get the behaviour about which Im talking.
Can you propose any solution to this problem?