Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. multiple selection in datagrid

multiple selection in datagrid

Scheduled Pinned Locked Moved C#
tutorial
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sudee
    wrote on last edited by
    #1

    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.

    S 1 Reply Last reply
    0
    • S Sudee

      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.

      S Offline
      S Offline
      sreejith ss nair
      wrote on last edited by
      #2

      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 **************************

      S 1 Reply Last reply
      0
      • S sreejith ss nair

        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 **************************

        S Offline
        S Offline
        Sudee
        wrote on last edited by
        #3

        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.

        S 1 Reply Last reply
        0
        • S Sudee

          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.

          S Offline
          S Offline
          sreejith ss nair
          wrote on last edited by
          #4

          //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 **************************

          S 1 Reply Last reply
          0
          • S sreejith ss nair

            //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 **************************

            S Offline
            S Offline
            Sudee
            wrote on last edited by
            #5

            Sreeji, Thank you very much. I appreciate your help. :) ====== code proj. rocks!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups