DataGridView Problem

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

    #1

    DataGridView Problem

    Hi all,

    I have a Datagridview and I have added columns to it it is bound to a
    dataset table that is created in the code. The columns order is set and
    at the design view it appears just as I want it (I have textbox 5
    columns and 1 button column that i want to appear at the end of the
    grid as last) but when I run the application the button column that is
    supposed to be last jumps to the second place.

    I have even tried to set the column order in code but with no luck.

    Can anyone help please?

  • Chris

    #2
    Re: DataGridView Problem

    Brano wrote:[color=blue]
    > Hi all,
    >
    > I have a Datagridview and I have added columns to it it is bound to a
    > dataset table that is created in the code. The columns order is set and
    > at the design view it appears just as I want it (I have textbox 5
    > columns and 1 button column that i want to appear at the end of the
    > grid as last) but when I run the application the button column that is
    > supposed to be last jumps to the second place.
    >
    > I have even tried to set the column order in code but with no luck.
    >
    > Can anyone help please?
    >[/color]

    Did you turn off datagridview.au togeneratecolum ns?

    Comment

    • Brano

      #3
      Re: DataGridView Problem

      Yes I did but no luck...

      I have actually sorted it out the thing is i am populating the grid in
      code and I had to write a code to bound the items.

      But the main trick is to execute it after the grid is bound.

      Example:


      Dim drExists As System.Data.Sql Client.SqlDataR eader
      drExists = PopulateDataRea der(strSQL, My.Settings.Con nStr)

      If drExists.HasRow s Then
      dgResults.DataS ource = PopulateDataSet (strSQL,
      My.Settings.Con nStr).Tables(0)
      pnlGrid.Visible = True
      AdjustColumnOrd er()
      End If

      Private Sub AdjustColumnOrd er()

      With dgResults
      .Columns("DateI n").DisplayInde x = 0
      .Columns("CustS urname").Displa yIndex = 1
      .Columns("Middl eName").Display Index = 2
      .Columns("DOB") .DisplayIndex = 3
      .Columns("PostC ode").DisplayIn dex = 4
      .Columns("btnSe lect").DisplayI ndex = 5
      End With

      End Sub

      Comment

      Working...