Flexgrid select items by code

Posted by: kisar on 4 October 2021, 9:30 am EST

    • Post Options:
    • Link

    Posted 4 October 2021, 9:30 am EST

    Hi

    im using the flexgrid, i need to select some rows (0,4,8,10)

    I found only this solution >> fgrid.Rows[i].Selected=True;

    The rows appear selected but >>fgrid.SelectedItems.Count==0

    I also noticed that if i do >> fgrid.SelectedItems.Clear();

    inside the rows is still fgrid.Rows[i].Selected=True;

    Why they dont match?

    What’s the best way to proceed?

    Thanx

  • Posted 5 October 2021, 9:09 am EST

    Hi,

    Through SelectedItems you can get a collection of data items corresponding to the currently selected rows. i.e., after>> fgrid.Rows[i].Selected=True; >> fgrid.SelectedItems.Count will update and shouldn’t be 0, if fgrid.Rows[i] is a valid bounded row.

    fgrid.SelectedItems.Clear(); will not work, this is design behavior that SelectedItems will internally sets data items corresponding to the currently selected rows.

    However, you can clear SelectedItems as: (see code snippet)

    
    foreach (var row in fgrid.Rows.Where(x => x.Selected == true))
          row.Selected = false;
    fgrid.SelectedIndex = -1;
    
    

    Please refer the attached sample for the same : FlexgridSelectedItems.zip

    Best Regards,

    Nitin

  • Posted 6 October 2021, 5:00 am EST

    Thank you,

    i will change the fgrid.SelectedItems.Clear() command

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels