how to set gridview.Column

Post Reply
bill-lancaster
Posts: 71
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

how to set gridview.Column

Post by bill-lancaster » Friday 27th September 2019 6:46am

I must be missing something here!
I want to set the column from code.
GridView1.Column = 2
But Print GridView1.Column shows "-1"

Any ideas welcome

User avatar
cogier
Site Admin
Posts: 322
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: how to set gridview.Column

Post by cogier » Friday 27th September 2019 7:18am

Hi Bill.

You need Gridview1. Columns. Count = 2.

And a useful trick to use after you have filled your Gridview is to auto arrange the Columns widths with: -

Gridview1. Columns. Width = - 1

bill-lancaster
Posts: 71
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Re: how to set gridview.Column

Post by bill-lancaster » Friday 27th September 2019 7:34am

Thanks for the quick response.
I have already set up the table with GridView1.Columns.Count = 3 and filled the table with data.
I'm using the _Sort event but would like to force the sorting of a column from code. So after setting up the gridview:-

Code: Select all

Public Sub Button1_Click()
  GridView1.Column = 2
  Print "CC";; GridView1.Column

End
is where the problem is.

bill-lancaster
Posts: 71
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Re: how to set gridview.Column

Post by bill-lancaster » Friday 27th September 2019 8:33am

GridView1.Columns.Sort = 2
does it.
Regards

Post Reply