arranging columns at runtime in a datagrid

  • Thread starter Thread starter Nick Caramello
  • Start date Start date
N

Nick Caramello

this may (and should) be absurdly simple, but I am having some difficulty
with the arrangement of columns in a datagrid - I want the user to be able
to arrange the columns in any order. I would have expected this
functionality to be available by setting a property, but I cannot find
(either in the help or by trial and error) a property that does this.

any ideas (including using a different component).

thanks in advance
Nick Caramello
 
Nick Caramello said:
this may (and should) be absurdly simple, but I am having some difficulty
with the arrangement of columns in a datagrid - I want the user to be able
to arrange the columns in any order. I would have expected this
functionality to be available by setting a property, but I cannot find
(either in the help or by trial and error) a property that does this.

any ideas (including using a different component).

Well, you could change the DataView appropriately, or look at
DataGrid.TableStyles which leads to (after a while)
DataGridColumnStyle. I *believe* that giving the appropriate sequence
of DataGridColumnStyles will effectively rearrange the columns, but I
can't say I've done it.
 
I believe that what you are suggesting would work if I wanted to arrange the
columns programatically - I dont. I want the user to be able to drag
columns into the order that they want them (and then I am going to save that
information so that the next time they start the application the columns
will be in the appropriate order, and for that I will use the dataview).
 
Nick Caramello said:
I believe that what you are suggesting would work if I wanted to arrange the
columns programatically - I dont. I want the user to be able to drag
columns into the order that they want them (and then I am going to save that
information so that the next time they start the application the columns
will be in the appropriate order, and for that I will use the dataview).

But I would imagine you could hook up some drag and drop events so that
when the user dragged the column, you would *then* programatically
reorder the columns and store the preference.

Having not done any drag and drop work myself, I wouldn't know how to
start on that side of things - but it's relatively unrelated to the
actual changing of column order.
 
Back
Top