|
-
Jul 10th, 2006, 04:56 AM
#1
Thread Starter
Member
[RESOLVED] Datagrid - columns width
The problem is when the program is run the columns in the datagrid are a set width irrespective of the length of the data in the column, which looks rubbish.
My question is how can i set the column widths of the datagrid, but better still how can i check the length of the data in the column and make the width of the column big enough to accommodate it??
if its not possible with the datagrid then is there a component that i can use with a ADO connection to mySQL database that has this ability?
Any help much appreciated
-
Jul 10th, 2006, 10:17 AM
#2
Re: Datagrid - columns width
I have no idea about the DataGrid (like most regulars here, I dont use it), but you can easily resize the columns in a FlexGrid, as shown here. This may be enough for you to work out how to do the same for the DataGrid.
..if not, see the "fill flexgrid" link in my signature to see how to put data into it from a database.
-
Jul 10th, 2006, 10:46 AM
#3
Thread Starter
Member
Re: Datagrid - columns width
Thanks for your reply.
I have found how to set the width in code to an exact value
VB Code:
dg1.Columns(0).width = 2000
pretty simple really,
but still not found how to get the longest data in each column to dictate the width of that column.
Is this possible with the flexgrid?
Out of interest what so bad about a datagrid that makes no one here use them?? Or whats so good about a flexgrid??
-
Jul 10th, 2006, 11:00 AM
#4
Re: Datagrid - columns width
To find out how to get the longest data, see the flexgrid example - all you need to change in it is the code to set the column width.
A DataGrid is a Bound control, and all things bound are Evil (apparently this has changed with VB.Net, but it has always been the case in "Classic" VB).
Bound controls make it a little easier to do the basics (so are good to learn with), but as soon as you try to do anything slightly more complex (or change their behaviour in a "simple" way) then things can get very complicated very quickly, or just aren't possible.
See this link (from Hack's signature) for a bit more info: http://www.vbrad.com/Articles/art_binding_evil.htm
To be honest, a DataGrid is by far the 'best' of the bound controls, as the equivalent code for a FlexGrid in quite large/complex the first time you write it (but that code can be placed in a class/module and used in other projects).
Last edited by si_the_geek; Jul 10th, 2006 at 11:04 AM.
-
Jul 11th, 2006, 03:48 AM
#5
Thread Starter
Member
Re: Datagrid - columns width
Cheers for the info and the read si. I have implemented the flexigrid this morning and its lookin good.
Just have to learn how to make it do what i want it to now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|