Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
106
Moving Columns
posted

Hi,

We're using version 14.1.20141.2138 if XamGrid and are having problems with the xamgrid columns. I need to move certain columns programmatically. I'm following some older sample from the forums that suggest the following:

ColumnLayout.Columns.Remove(column)
ColumnLayout.Columns.Insert(index, column) 

Occasionally I end up having an exception when inserting the column that the key already exists. I even tried to check if the key exists like

if (ColumnLayout.Columns[key] == null) // then do this...

I get the same crash even after checking. I suspect, I'm trying to do this incorrectly. What would be the correct way to move a column?

14.1.20141.2138

Parents
No Data
Reply
  • 34430
    Offline posted

    Hello ariman,

    Thank you for your post!

    You are correct in the way that you are moving your columns. You should remove the column and then reinsert it at a different area in the XamGrid. I have created a sample project, but I cannot seem to reproduce this behavior you are seeing when removing and reinserting a column in the XamGrid. I have attached the sample project I have used to test this, which has a button that removes a random column from the grid and then reinserts it at a random index on every click. Please test sample project on your machine. My tests were also made using version 14.1.20141.2138.

    Since I cannot seem to reproduce this behavior you are seeing, it is very possible that our projects are a bit different. If you do not reproduce this behavior with the sample project I have attached, would it be possible for you to please modify it so that it does reproduce the behavior you are seeing and send it back? Alternatively, would it also be possible for you to please provide more details on the properties you are setting in your XamGrid, along with the type of data source you have bound to it?

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

    XamGridMoveColumnsCase.zip
Children