invert rows & columns

Hey Guys,

I have a question that's been bugging me for the last two days. I have a datagridview that I'd like to display as follows - i'd like the rows to be shown as columns, and columns to be shown as rows. That way, the user can enter data from left to right, as opposed to top-down.

This doesn't seem too complicated, and I would think there might be a simple toggle-like functionality somewhere to enable this

Any ideas

best,
Shiney



Answer this question

invert rows & columns

  • mms18

    Manually build the DataSet/DataTable.

    I would populate a DataSet / DataTable as normal, i.e. rows = rows and columns = columns. Then in a business module, manually design a new DataSet / DataTable based on the rows = columns and columns = rows.

    Then pass the new DataSet up to the UI and bind a grid to it. When you'd normally save any changes, pass the data set back down to the business module which reverses the process and then sets the normal original data set to reflect the changes. Then the business module passes the changed original data set down to the data access component and SqlAdapter.Save (or whatever method you use).

    Tricky part may be setting the row state of the changed rows in the last version of the original data set.

    This isn't as 'unique' as you'd think. I am preparing to do something similar myself. Since there isn't an straight-forward way to represent crosstabed or pivot data let alone keep it editable. I will have to go through this 'adapter' method.

    Best regards,

    CN



  • Steven Habex

    Thanks guys. I'm worried about the performance implications of inversion, but let's see how it goes.


  • coreus

    Back in VS, while trying to implement your idea, I noticed that what I'd really like to do is replicate the functionality of the "Properties" window - you know the one that you most likely use to change properties of Windows Forms Items. I wonder how that was done Was it created using datasets I would think not, since there might be items with over 100 properties, and this might have a performance penalty - as Mike mentioned.

    Any ideas on how one can go about replicating the properties part of the Properties bar

    Thanks!!!

    Jay

  • Janee

    The DataGridView isn't designed to handle inverted rows and columns, so doing what Carpe says might be a way to investigate. Note that the grid does not work well with large number of columns you'll see performance issues since columns are not virtual doesn't like rows are.

    -mark
    DataGridView Program Manager
    Microsoft
    This post is provided "as-is"


  • invert rows & columns