Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2235
firing RowSelectionChanged event manually
posted

Hi folks,

using 11.2

I have some buttons on my web form, one of them sets the SelectedRowCollection,  the following code snippet should explain.

 Dim selectedRows As SelectedRowCollection = webdatagrid1.Behaviors.Selection.SelectedRows
        selectedRows.Clear()
        selectedRows.Add(data_grid1.Rows(0))

After this code snippet I want to call the RowSelectionChanged property, as it isn't firing on the selectedRows.Add event.

Is there a way to call the webdatagrid1.RowSelectionChanged event?
Parents
No Data
Reply
  • 37874
    posted

    Hi Daryl007,

    You can achieve this using something like the following code:

    Protected Sub Button2_Click(sender As Object, e As EventArgs)
         Dim currentlySelectedRows As SelectedRowCollection = WebDataGrid1.Behaviors.Selection.SelectedRows
         Dim newSelectedRows As New SelectedRowCollection(WebDataGrid1) 
         newSelectedRows.Add(WebDataGrid1.Rows(1))
         Dim eventArgs As New SelectedRowEventArgs(currentlySelectedRows, newSelectedRows)
         currentlySelectedRows.Clear()
         currentlySelectedRows.Add(newSelectedRows(0))
         WebDataGrid1_RowSelectionChanged(WebDataGrid1, eventArgs)
    End Sub

    Let me know if this helps.

Children