I have a Windows Form GridView object that I am populating. I need to allow the user to change the order of items in the list. To do this, I have two buttons, MoveUp and MoveDown to let them. For simplicity sake, I have left out a lot of error checking code from my post.
My problem is that I am calling the GridElement.BeginUpdate() and GridElement.EndUpdate() methods, and for the MoveUp it works just fine, however, oddly enough, the MoveDown causes a flicker effect, which is not supposed to happen (I think) if I am using these methods correctly.
Here is the portion of my code that is doing this action, as you can see the same code is running in both instances, I am just passing in a different change:
My problem is that I am calling the GridElement.BeginUpdate() and GridElement.EndUpdate() methods, and for the MoveUp it works just fine, however, oddly enough, the MoveDown causes a flicker effect, which is not supposed to happen (I think) if I am using these methods correctly.
Here is the portion of my code that is doing this action, as you can see the same code is running in both instances, I am just passing in a different change:
private
void btnMoveUp_Click(object sender, EventArgs e)
{
MoveCurrentItem(-1);
}
private void btnMoveDown_Click(object sender, EventArgs e)
{
MoveCurrentItem(1);
}
private void MoveCurrentItem(int indexChange)
{
if (radgvScriptsList.SelectedRows.Count == 1)
{
radgvScriptsList.GridElement.BeginUpdate();
MultiScriptFile file = GetSelectedFile();
int oldIndex = Files.IndexOf(file);
Files.Remove(file);
Files.Insert((oldIndex + indexChange), file);
radgvScriptsList.Rows[(oldIndex + indexChange)].IsCurrent = true;
radgvScriptsList.GridElement.EndUpdate();
}
}