Home Forums WinForms controls Xceed Grid for WinForms Double click event handler inactive when datasource changed

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13651 |

    <b>Following is the some contents from my code. The grid is a bound one. The datasource is populated depends on the selection in the combo. Selection 1 in the combo is default thus populating the grid during form load. When I change the table in the datasource, doubleclick hander does not firing.</b>

    Anyone there to assist me…? (<color=”blue”>who else other than Tommy (h) </color>)

    <u>Code Contents:</u>

    Private Sub formLoad………….
    ……………
    ……………
    Dim cell As DataCell
    For Each cell In grid.DataRowTemplate.Cells
    AddHandler cell.DoubleClick, AddressOf updateMenuStatus2
    Next
    ……………
    ……………
    End Sub

    Private Sub cboFranch_SelectedIndexChanged…..
    fillGridContents
    End Sub

    Private Sub fillGridContents
    Try
    If cboFranch.SelectedValue = 1 Then
    sqlQry = “select field1,field2,field3 from table1 <color=”red”> ‘double click fires the event correctly</color>
    ElseIf cboFranch.SelectedValue = 2 Then
    sqlQry = “select field4,field5,field6 from table1 <color=”red”> ‘double click fires the event correctly</color>
    ElseIf cboFranch.SelectedValue = 9 Then
    sqlQry = “select field1,field2,field3 from table2 <color=”red”> ‘table change.. double click does not fire the event</color>
    End If
    categ2DS.Reset()
    grid.DataSource = Nothing
    sqlDa.SelectCommand = New SqlCommand(sqlQry, sqlCon)
    sqlDa.Fill(categ2DS, “categ2”)
    ‘grid.BeginInit()
    grid.DataSource = categ2DS.Tables(“categ2”)
    ‘grid.EndInit()
    showMenuStatus_categ2()
    Catch ex As Exception
    ‘MsgBox(ex.Message)
    End Try
    End Sub

    Imported from legacy forums. Posted by PETE (had 3697 views)

    User (Old forums)
    Member
    Post count: 23064

    The problem is: if you change the DataSource, all the rows and cells in the grid are deleted and created again. That means that all the events for the rows and cells are gone.
    However, since you’ve added the handlers to the cells of the DataRowTemplate, they should still work.
    Try this:<code>Private Sub formLoad…..
    ….
    AddHandler grid.AddingDataRow, AddressOf addingDataRow
    ….
    End Sub
    Private Sub addingDataRow(sender As Object, e As AddingDataRowEventArgs)
    Dim row As Xceed.Grid.DataRow = e.DataRow
    Dim cell As Xceed.Grid.DataCell
    For Each cell In row.Cells
    AddHandler cell.DoubleClick, AddressOf updateMenuStatus2
    Next
    End Sub</code>
    This should add the cell doubleclick handler, each time a new datarow is added.

    Imported from legacy forums. Posted by Tommy (had 146 views)

    User (Old forums)
    Member
    Post count: 23064

    Thank you Tommy. My salutes to you.

    Imported from legacy forums. Posted by PETE (had 357 views)

    User (Old forums)
    Member
    Post count: 23064

    Here is one more question related to this same topic.

    I do format the columns as below, after the datasource is definded.

    grdcate2.DataSource = categ2DS.Tables(“categ2”)
    With grdcate2
    .BeginInit()
    .Columns(0).Visible = False
    .Columns(1).Visible = False
    .Columns(2).Visible = False
    .Columns(3).Width = 400
    .EndInit()
    End With

    The problem is, if the datasource is changed the format is not refreshed. For example width of column 3 is not as 400.

    Where I should place this code?

    Imported from legacy forums. Posted by PETE (had 428 views)

    User (Old forums)
    Member
    Post count: 23064

    That code looks correct, to me. I don’t really see what’s wrong. Perhaps you should contact Xceed support for this problem.

    Imported from legacy forums. Posted by Tommy (had 4383 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.