Home Forums WinForms controls Xceed Grid for WinForms Cannot get MoveCurrentRow to work…

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15028 |

    Hello –

    I have a grid with 2 bitmap columns that the user can use to move the row up and down within the grid. I know that gridcontrol.MoveCurrentRow(Direction) should accomplish this but I cannot get it to work.

    I have made sure that the other rows, etc. have CanBeCurrent set to true. Is there anything I am missing? here is my code

    private void UpRow_Click(object sender, EventArgs e)
    {
    this.MyGrid.MoveCurrentRow(Xceed.Grid.VerticalDirection.Up);
    }

    I have attached this to all the “up” cells and know that this method is being called – the rows just won’t move.

    Thanks,
    Eric

    Imported from legacy forums. Posted by Eric (had 1957 views)

    User (Old forums)
    Member
    Post count: 23064

    First, MoveCurrentRow refers to the CurrentRow property, which means the row that is currently selected. If you change the CurrentRow property, it is the row that is currently selected that changes. The MoveCurrentRow method is in fact changing the CurrentRow property. It is not a way to move a specific row around the gird.

    Second, it is not possible to change the position of a row within the DataRows collection. You need to use a workaround to do this. Basically, you need to have an invisible column which is in fact an index of the rows on which you sort the grid. Then you simply change the index of a row, and resort the grid.

    Here is a <a href=”http://www.xceedsoft.com/cs/download/XceedGrid/CSharp/MoveRows.zip”>sample</a&gt; application that shows how to accomplish this.

    Imported from legacy forums. Posted by André (had 3024 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.