Home > Software design >  How to get selected row value from C1FlexGrid
How to get selected row value from C1FlexGrid

Time:10-05

I have C1FlexGrid in my form with multiple rows. I want to select random rows and get those selected row value.

Selection Mode:

this.CliAcctHolderGrid.SelectionMode = C1.Win.C1FlexGrid.SelectionModeEnum.ListBox;

Function Code:

   private void Submit(object sender, EventArgs e)
   { 
       List<string> holderIdentificationId = new List<string>(); 
       if (CliAcctHolderGrid.RowSel >= 1)
       {
           for (int CliAcctHolder = 1; CliAcctHolder <= CliAcctHolderGrid.Row; CliAcctHolder  )
           {
               C1.Win.C1FlexGrid.Row rowSel = CliAcctHolderGrid.Rows[CliAcctHolder];  
               holderIdentificationId.Add((string)rowSel["HolderIdentifierId"]); 
            } 
        }  
   }

From the code I have done, I am getting values which I didn't selected. Getting all values from the grid. Can anyone please suggest me where I am making a mistake.

CodePudding user response:

private void Submit(object sender, EventArgs e)
    {
        List<string> holderIdentificationId = new List<string>();
        if ( CliAcctHolderGrid.RowSel >= 1 )
        {
            foreach(C1.Win.C1FlexGrid.Row dr in CliAcctHolderGrid.Rows.Selected)
            {
                holderIdentificationId.Add( (string)dr["HolderIdentifierId"] );
            }
    
        }
    }
  • Related