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?
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.
Using your sample as a guideline, I ALMOST have it working.
However, the issue that remains is that the new row is not physically selected or "high-lighted", so that if I do click on another row, the rowchangeevent fires again, but with the incorrect information.
Any clues?
Hello Daryl007,
Could you clarify what is exactly your issue. You can refer to the attached sample - when you click the button, the second row is selected and highlighted and RowSelectionChanged fired. The label is updated with the index of that row. Then you can select different row from the grid and the label will be updated again.
The script is working up to a point.
The only difference mine has with yours is that.. I call a sub to set a label. before executing the RowSelectionChanged event..
So, the record advances, the function that updates a label works, but the row in the grid is still not highlighted, the previous row is.
Dim iindex As Integer iindex = wdgFact.Behaviors.Selection.SelectedRows.Item(0).Index If iindex = wdgFact.Rows.Count - 1 Then Return End If Dim currentlySelectedRows As SelectedRowCollection = wdgFact.Behaviors.Selection.SelectedRows Dim newSelectedRows As New SelectedRowCollection(wdgFact) newSelectedRows.Add(wdgFact.Rows(iindex + 1)) currentlySelectedRows.Clear() currentlySelectedRows.Add(wdgSubFactor.Rows(iindex)) Dim eventArgs As New SelectedRowEventArgs(currentlySelectedRows, newSelectedRows) RecordCount(iindex + 1, StandardList.Count) wdgFact_RowSelectionChanged(wdgSubFactor, eventArgs)
So, the difference in this working or not working was changing the following line from
currentlySelectedRows.Add(wdgFact.Rows(iindex))to
currentlySelectedRows.Add(newSelectedRows)It now works correctly...But why?
I'm glad to hear you got this working.
I would need a small sample, reproducing the behavior you have described, in order to be able to tell what is causing it.