Moving rows in Datagrid view control in C#
I'm developing windows Application using C#... The App is basically a search app. when a support user(
assume the support Gal :) ) searches for specific record... the query returns say some 100 rows and i display those data in a DATAGRIDVIEW control...
I need couple of things in this.:
1). In my Windows Form i have two buttons for sorting the Queue say like UP and DOWN arrow.
- The user will select a single row in the Search Results list and then select the âUpâ or âDownâ navigation buttons to order the jobs
---> The âUPâ navigation button will update the database to indicate the order this job will be executed (decrement the order by 1)
---> The âUPâ navigation button will move single jobs up in the queue by 1 row, causing the Search Results to refresh showing the new location of the selected job
and vice - versa on click of the DOWN arrow...((increment the order by 1))
2) when the user click UP arrow she should be able to go directly to the row where the Status is of type Queued and the place the selected row before this (queued ) row..
The columns i have:
JobType Country TimeStarted TimeFinshed Status
CP SA "2007-02-17 "2007-05-07 Success
00:00:00.000" 00:00:00.000"
IP NA "2007-02-17 "2007-02-18 Queued
00:00:00.000" 00:00:00.000"
PP FR "2007-02-16 "2007-02-17 Failed
00:00:00.000" 00:00:00.000"
PG IN "2007-02-17 "2007-02-19 Queued
00:00:00.000" 00:00:00.000"
- The âUpâ and âDownâ navigation buttons only apply to jobs that are of a status âQueuedâ
Pls help me out ... I am desperate and my life sucks here....
Code :
Datagrigview :dgrBJSList
I tried to get the index as ...
foreach (DataGridViewRow SelectedRow in dgrBJSList.SelectedRows)
{
string val = SelectedRow.Cells[5].Value.ToString();
if (val == "REQUESTED")
{
int xRow = (int)dgrBJSList.Rows.IndexOf(SelectedRow);
}
}
|