problem with data grid after clicked the columns header

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff

    problem with data grid after clicked the columns header

    hi there,

    Does anyone know which event is been called after any column hearders had
    been clicked?

    My problem is that the data grid lost selected the row and started an
    endless loop after I clicked any columns header in the data grid.

    thanks

    Jeff


  • Ken Tucker [MVP]

    #2
    Re: problem with data grid after clicked the columns header

    Hi,

    Add a handler to the dataviews list changed event. If you are using
    a datatable as the datasource use the datatable's defaultview list changed
    event.

    Dim ds As New DataSet

    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
    System.EventArg s) Handles MyBase.Load

    Dim strConn As String

    Dim strSQL As String

    Dim da, daEmployees As OleDbDataAdapte r

    Dim conn As OleDbConnection

    strConn = "Provider = Microsoft.Jet.O LEDB.4.0;"

    strConn &= "Data Source = Northwind.mdb;"

    conn = New OleDbConnection (strConn)

    da = New OleDbDataAdapte r("Select * From Categories", conn)

    da.Fill(ds, "Categories ")

    daEmployees = New OleDbDataAdapte r("Select * From Employees Order by
    LastName, FirstName", conn)

    daEmployees.Fil l(ds, "Employees" )

    DataGrid1.DataS ource = ds.Tables("Cate gories")

    DataGrid2.DataS ource = ds.Tables("Empl oyees")

    AddHandler ds.Tables("Empl oyees").Default View.ListChange d, AddressOf
    ListChanged

    End Sub



    Private Sub ListChanged(ByV al sender As Object, ByVal e As
    System.Componen tModel.ListChan gedEventArgs)

    Dim hti As DataGrid.HitTes tInfo

    Dim pt As Point

    pt = DataGrid2.Point ToClient(Me.Mou sePosition)

    hti = DataGrid2.HitTe st(pt)

    Trace.WriteLine (String.Format( "Sort on column {0}", hti.Column))

    End Sub



    Ken

    ------------------------
    "Jeff" <hotjunk03@hotm ail.com> wrote in message
    news:0oednWO_Nv JOs8_cRVn-pQ@rogers.com.. .
    hi there,

    Does anyone know which event is been called after any column hearders had
    been clicked?

    My problem is that the data grid lost selected the row and started an
    endless loop after I clicked any columns header in the data grid.

    thanks

    Jeff



    Comment

    Working...