i have a datagrid in form load,
how can i change the columns width and height ?
i want to change with different size each column and not all the same
(with code if you can)
Printable View
i have a datagrid in form load,
how can i change the columns width and height ?
i want to change with different size each column and not all the same
(with code if you can)
Something like this?
vb Code:
Private Sub Form_Load() With DataGrid1 .Columns(0).width = '<~~ your value .Columns(1).width = '<~~ your value '~~> and so on... End With End Sub
1) Which line gives you the error?
2) How many columns are there in the Grid?
3) Also the value of the width is not a string. It should be
DataGrid.Columns(0).Width = 1000
in line DataGrid.Columns(2).Width = "3000" i get the error
i have 2 columns , but i want 27 columns as default
i made the change in " " but also the same error
If you don't have a column, you cannot set a width to it :)
Create columns in design/runtime and then set the width to it...
Before I answer that question... What are you storing in Datagrid? Where is the data coming from?
Is that an Access database?
* .ColWidth() requires number, take out the quotes.
* .ColWidth() is in twips. If you want to have column width proportional to the width then write
.ColWidth(2) = .Width * 0.1 ' width of column number 2 is 10% of the width.
To set number of columns use
.Cols = 10 ' 10 columns, numbered 0..9
Hi I am writing a small tutorial for you on how to use datagrid with access database.... I will upload the same in another hour or so... I am at the office and I need to multitask :D
Here in my next post :)
Give me another half an hour... just came back from office....
Phew here it is....
Hope this helps....
Glad to be of help :)
Do remember to mark your thread resolved ;) Check my signature on how to do it...
Sorry, it was for flexgrid...
I want to increase or decrease height of my datagrid based on the records from the database. For example, If there are 10 rows then datagrid should set its height exactly to fit 10 rows. Height should not be more than the area covered by rows. I found code for 2005 version but that's not working in VB6. Please help