Results 1 to 9 of 9

Thread: Changing Dbgrid Col width

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 1999
    Location
    Freeport
    Posts
    204

    Post

    Can you change a Dbgrid Col width

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    Hi, Scott! Merry Christmas.
    At design time you can set columns width in Property Page, Layout Tab. If you don't want the user be able to change the size of column , uncheck AllowSizing.
    At run time:

    Dim Co As Column
    Dim Co1 As Column
    Set Co = DBGrid1.Columns(0)
    Set Co1 = DBGrid1.Columns(1)

    Co.Width = 1000
    Co1.Width = 2000

    Hope it will help you.
    Larisa

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 1999
    Location
    Freeport
    Posts
    204

    Post

    Sorry LG but this did not change the Col Width

  4. #4
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    Try this:

    DBGrid1.row = 1
    DBGrid1.colwidth(0) = "2000"

    This would set the col width of the first col, 2 row.

  5. #5
    Guest

    Post

    You can try this with dbgrid 5 or higher..

    ' item 0 is the first column
    DBGrid1.Columns.Item(0).Width = 1000

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Apr 1999
    Location
    Freeport
    Posts
    204

    Post

    No not yet. I not sure where ya'll came up with combination of property but they don't belong together.

  7. #7
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    lol, well you can't fault us for trying :-) What version of VB are you using? And which DBGrid? The one that ships with VB or a different one?

  8. #8
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    I just tried this and it worked fine:

    grdSamples.ColWidth(0) = grdSamples.ColWidth(0) + 1000

    I put this in a button and each time it would add 1000 to it. How does it not work on yours?

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Apr 1999
    Location
    Freeport
    Posts
    204

    Post

    I thank you for your help. I am using VB5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width