multiple selection in datagrid
-
Right now I am working with DataGrid.CurrentRowIndex how to do if I have to select multiple rows. Thank you, ====== Yo need a brain to code.
hi, What is your real requirement ?. We can select more than one record in a datagrid. Select() method is used to select a perticular row. And Unselect() method doing the reverse of Select(). you can check whether a perticular row is selected or not by using IsSelected() method. I recommand you to read the DataGrid Class description in MSDN.;) ************************** S r e e j i t h N a i r **************************
-
hi, What is your real requirement ?. We can select more than one record in a datagrid. Select() method is used to select a perticular row. And Unselect() method doing the reverse of Select(). you can check whether a perticular row is selected or not by using IsSelected() method. I recommand you to read the DataGrid Class description in MSDN.;) ************************** S r e e j i t h N a i r **************************
Hello Sreejit, I have used DataGrid_MouseUp() event and then used DataGrid.CurrentRowIndex to get the current row.
private void DataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { int i = DataGrid.CurrentRowIndex; }
But how can I get multiple rows index if I have selected multiple rows. like this>>private void DataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { for (int i = 0; i <= DataGrid.CurrentRowIndexes:confused:; i++) { int j = DataGrid.CurrentRowIndexes[i]; } }
====== Yo need a brain to code. -
Hello Sreejit, I have used DataGrid_MouseUp() event and then used DataGrid.CurrentRowIndex to get the current row.
private void DataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { int i = DataGrid.CurrentRowIndex; }
But how can I get multiple rows index if I have selected multiple rows. like this>>private void DataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { for (int i = 0; i <= DataGrid.CurrentRowIndexes:confused:; i++) { int j = DataGrid.CurrentRowIndexes[i]; } }
====== Yo need a brain to code.//For collecting the index of selected records ArrayList Ar=new ArrayList(); private void DataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { for (int i = 0; i <= DataGrid.CurrentRowIndexes; i++) { /*this line will help you to deside whether row is selected or not. If yes then it will return a bool value. Else will return a false value.*/ if(DataGrid.IsSelected(i) Ar.Add(DataGrid.CurrentRowIndexes[i].ToString()); else continue; } } So finally you will get all index of selected row in your ArrayList. Remaing is upto you to design based on your requirement.;) ************************** S r e e j i t h N a i r **************************
-
//For collecting the index of selected records ArrayList Ar=new ArrayList(); private void DataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { for (int i = 0; i <= DataGrid.CurrentRowIndexes; i++) { /*this line will help you to deside whether row is selected or not. If yes then it will return a bool value. Else will return a false value.*/ if(DataGrid.IsSelected(i) Ar.Add(DataGrid.CurrentRowIndexes[i].ToString()); else continue; } } So finally you will get all index of selected row in your ArrayList. Remaing is upto you to design based on your requirement.;) ************************** S r e e j i t h N a i r **************************