Results 1 to 5 of 5

Thread: Column width in Datagrid - units of measurement?

  1. #1

    Thread Starter
    Hyperactive Member billwagnon's Avatar
    Join Date
    Jul 1999
    Location
    St. Louis, Missouri, Mississippi Valley
    Posts
    290

    Post

    I have a Datagrid with four columns. Two of the columns can be turned off (set to zero width). This works great !

    I want to set the columns so they aren't in total any wider than the datagrid width. So what I did was set three of the widths, then set the fourth one equal to the datagrid width, minus the widths of the other three. Good in theory, but it doesn't work . Are the columns and datagrid measured differently?

    Thank you in advance for your help!

  2. #2

    Thread Starter
    Hyperactive Member billwagnon's Avatar
    Join Date
    Jul 1999
    Location
    St. Louis, Missouri, Mississippi Valley
    Posts
    290

    Post

    anyone? anyone? Bueller?

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    What you described you did should work. Post your code or email me and I'll take a look at it.

    ------------------
    Marty

  4. #4

    Thread Starter
    Hyperactive Member billwagnon's Avatar
    Join Date
    Jul 1999
    Location
    St. Louis, Missouri, Mississippi Valley
    Posts
    290

    Post

    Here it is Marty - thank you!

    Set dgPlanBox3.DataSource = ThirdRsGrid

    With dgPlanBox3
    .Columns(2).Width = 0 'mgr name
    .Columns(3).Width = 0 'mgr name
    .Columns(1).Width = .Width - .Columns(0).Width ' - .Columns(1).Width
    End With

    With dgPlanBox3 'plan name column minus the other widths
    dgPlanBox3.Columns(1).Width = .Width - .Columns(0).Width - .Columns(2).Width - .Columns(3).Width
    End With

  5. #5
    Member
    Join Date
    Oct 2003
    Posts
    41
    You might want to try this

    '---------------------------
    dim iWidth as Integer
    'Set first two columns
    dgPlanBox3.Columns(0).Width = 0
    dgPlanBox3.Columns(1).Width = 0
    'set an integer to the caculated remaing width this will round to a whole number
    iWidth = dgPlanBox3.Width - (dgPlanBox3.Columns(0).Width + dgPlanBox3.Columns(1).Width)

    'set your third column to the remainder
    dgPlanBox3.Columns(2).Width = iWidth

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