This is a migrated thread and some comments may be shown as answers.

Changing current row and mainaining multiselection

2 Answers 71 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jill-Connie Lorentsen
Top achievements
Rank 1
Jill-Connie Lorentsen asked on 19 Oct 2009, 09:59 AM

In my GridView the user selects a number of rows, and then asks to do some processing based on each of the selected rows, one by one.

The rows are typically selected by "normal" multirow selection, by pressing the shift or ctrl key and clicking the rows/range of rows in question. The last clicked row is then selected, and the arrow to the left is on this row, while the others are marked with blue.

When the processing begins the first (topmost) row and then the rest in sequence. I would like the arrow to follow the row in progress, but by setting CurrentRow, the "multiselection" is cleared, and only the CurrentRow is marked with blue.

Is there a way to programatically move the arrow to the left without clearing the "multiselection"?

Regards, Jill-Connie Lorentsen

2 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 19 Oct 2009, 01:35 PM
Hi Jill, thank you for contacting us.

You can change the visual appearance of GridRowHeaderCellElement when handling ViewCellFormatting event. Use the Tag property of GridViewRowInfo to indicate whether the row is processed. Here is a sample:

bool processingRows;
 
private void button2_Click(object sender, EventArgs e)
{
    processingRows = true;
    GridViewRowInfo oldRow = null;
    foreach (GridViewRowInfo row in this.radGridView1.SelectedRows)
    {
        if (oldRow != null)
        {
            oldRow.Tag = null;
        }
        row.Tag = true;
        oldRow = row;
        this.radGridView1.GridElement.Update(GridUINotifyAction.StateChanged);
        this.radGridView1.Refresh();
        Thread.Sleep(1000);
    }
    processingRows = false;
    this.radGridView1.GridElement.Update(GridUINotifyAction.StateChanged);
    this.radGridView1.Refresh();
}
 
void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement is GridRowHeaderCellElement)
    {
        if (processingRows)
        {
            if (e.CellElement.RowInfo.Tag != null)
            {
                e.CellElement.Image = ((GridTableElement)this.radGridView1.GridElement).CurrentRowHeaderImage;
            }
            else
            {
                e.CellElement.Image = null;
            }
        }
        else if (e.CellElement.RowInfo.Tag != null)
        {
            e.CellElement.RowInfo.Tag = null;
            e.CellElement.ResetValue(LightVisualElement.ImageProperty);
        }
    }
}

I hope this helps. If you have any additional questions, please write me back.

Sincerely yours,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jill-Connie Lorentsen
Top achievements
Rank 1
answered on 20 Oct 2009, 09:18 AM

Thank you, - that helped!

Tags
GridView
Asked by
Jill-Connie Lorentsen
Top achievements
Rank 1
Answers by
Jack
Telerik team
Jill-Connie Lorentsen
Top achievements
Rank 1
Share this question
or