Page 1 of 1

how to set gridview.Column

Posted: Friday 27th September 2019 6:46am
by bill-lancaster
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

Re: how to set gridview.Column

Posted: Friday 27th September 2019 7:18am
by cogier
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

Re: how to set gridview.Column

Posted: Friday 27th September 2019 7:34am
by bill-lancaster
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.

Re: how to set gridview.Column

Posted: Friday 27th September 2019 8:33am
by bill-lancaster
GridView1.Columns.Sort = 2
does it.
Regards