Flexgrid row select and focus (net8)

Posted by: devcode.ou on 7 July 2024, 8:51 am EST

    • Post Options:
    • Link

    Posted 7 July 2024, 8:51 am EST

    Hi

    i have problem to set the focus on a row in flexgrid (net 8)

    i attached a simple example

    • Starting the application
    • Select a row manually, lets say the number 6
    • push the button FOCUS > the button will select the row 0
    • you see correctly the row 0 selected

      Now i want to go to the next row pressing the down arrow key
    • first : i need to press the down arrow key twice
    • second : it will be selected the row 7, as the flexgrid “remember” the last row manually selected

    Is there a different and correct way to select a row that the one used?

    WpfApp_flexgridfocus.zip

  • Posted 9 July 2024, 3:02 am EST

    Hi,

    Selection and Cursor have different behaviors. You can update the Button_Click event handler as:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        if (flexgrid.SetCursor(0, 0))
            flexgrid.Select(0, 0, true);
    }

    Please refer the attached modified working sample: WpfApp_flexgridfocus_Mod.zip

    Regards,

    Nitin

  • Posted 9 July 2024, 3:27 am EST

    Hi

    yes its working for the selected row but still i have to press twice the down arrow key

    Thanx

  • Posted 9 July 2024, 7:42 am EST

    Hi,

    Apologize for the inconvenience.

    Once we are clicking on the button, the focus is lost from the FlexGrid, and the the first row is selected. In order to resolve this issue, you can focus the FlexGrid after selecting first row as:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        if (flexgrid.SetCursor(0, 0))
        {
            flexgrid.Select(0, 0, true);
            flexgrid.Focus();
        }                    
    }

    Please refer the attached modified sample: WpfApp_flexgridfocus_Mod2.zip

    Regards,

    Nitin

Need extra support?

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

Learn More

Forum Channels