Results 1 to 3 of 3

Thread: Flexgrid Column Name

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Location
    Wollongong. NSW. Australia
    Posts
    470

    Flexgrid Column Name

    G'day,

    I've searched and searched and tried different properties, but still can't do it.

    How do I give a msflexgrid or mshflexgrid a column name without getting it from the datasource. I want different names to what is available in the database.

    Peter

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Flexgrid Column Name

    The easy way is to create some alliases while building sql statement so column names will appear in the way you want:
    VB Code:
    1. strSQL = "Select OrderID As [Order Id], Freight As [Total Freight] from Orders"
    2.    
    3.     Set adoRst = New ADODB.Recordset
    4.     With adoRst
    5.         .CursorType = adOpenKeyset
    6.         .LockType = adLockOptimistic
    7.         .Open strSQL, adoConn, , , adCmdText
    8.     End With
    9.    
    10.     HFGrid.Clear
    11.     Set HFGrid.Recordset = adoRst
    NOTE: sql will vary depending on the database you might have (sample above is for Access 2K).

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Flexgrid Column Name

    When we do a SELECT that we know is going into a FLEXGRID (we use STORED PROCEDURES) - we do something like this:

    Code:
    SELECT column1 "Heading for Column 1 - extra spaces                           "
              ,column2 ">Heading for Col 2 - right justified"
              ,column3 "^Heading for Col3 - centered"
              FROM...
    Then in the VB side, we use the .FORMATSTRING property of the flexgrid to build the headings from the COLUMN NAMES of the RECORDSET.

    We also put special tokens in place sometimes - heading like "~wide~Heading". When the VB-side sees "~wide~" is searches all the cells in that column for the widest entry (using .TEXTWIDTH) and then forces that column to be that size - in TWIPS.

    We have dozens of these special tokens.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

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