PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
how to make Dynamic Flex grid?-VBForums
Results 1 to 9 of 9

Thread: how to make Dynamic Flex grid?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    how to make Dynamic Flex grid?

    Hi,

    I want some information about flex grids and also guide me how to make it dynamic in the sense that at run time it build according to the records fetched from the db at run time.

    Regards,

  2. #2

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,091

    Re: how to make Dynamic Flex grid?

    ..and to fill it from a recordset, see the link in my signature.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Re: how to make Dynamic Flex grid?

    Thankx for your guidance.Please tell me that how to fix the size of the flex grids according to the records fetched from the database as I dont want scroll bars in that grid which appears in the code as u have provided.

    Regards,

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,091

    Re: how to make Dynamic Flex grid?

    Do you mean that you want to re-size the columns to the minimum size needed?

    If so, you can use the TextWidth function to find out the width of the text in a cell. Using a simple loop you can find the maximum width in a column, and set the column size to that (plus a few pixels for the border).

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Re: how to make Dynamic Flex grid?

    VB Code:
    1. wi = .CellFontWidth
    then how to use the colwidth..n also tell me is it the way to do?
    VB Code:
    1. .ColWidth(.CellHeight) = wi

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,091

    Re: how to make Dynamic Flex grid?

    That would work, but you need to change the .row & .col to move to each cell, and that is slow (partly because it fires multiple events).

    The TextWidth function is a member of the Form (and other objects too, but it's safest to use the form), and you need to pass the text to it, which you can get using the TextMatrix function of the grid.

    Assuming your grid has only one column, this would do the job:
    VB Code:
    1. Dim lngRow as Long
    2. Dim lngWidth as Long, lngMaxWidth as Long
    3.   With MsFlexGrid1 'change to the name of your grid
    4.  
    5.     lngMaxWidth = 0
    6.        'find the widest text in the column
    7.     For lngRow = .FixedRows to .Rows - 1 '(read all data rows - to check headers too, change [i].FixedRows[/i] to [i]0[/i])
    8.       lngWidth = Me.TextWidth(.TextMatrix(lngRow,[u]0[/u]))
    9.       If lngWidth > lngMaxWidth Then lngMaxWidth = lngWidth
    10.     Next lngRow
    11.        'set the column width  (adding a border, this code assumes the ScaleMode is Twip)
    12.     .ColWidth([u]0[/u]) = lngMaxWidth + Screen.TwipsPerPixelX * 4
    13.  
    14.   End With
    ..to do the same for all columns, put this inside another loop (similar to the lngRow one) for the columns. The underlined values in this code are the column number.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Re: how to make Dynamic Flex grid?

    Thanks for your guidence,After all this it is also giving scroll bars,so what can be its solution?

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,091

    Re: how to make Dynamic Flex grid?

    You will get scroll bars if the columns (or rows) are too large for the visible area.

    The simplest way to avoid it is to make the width (or height) of the grid bigger. The size you need would be the total size of the columns, plus the width of the grid lines (I think one pixel each), plus the size of the grids border (which I think is 4 pixels in total, but I could be wrong).

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width