CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 1999
    Location
    Texas
    Posts
    6

    formatting data in MSHFlexGrid

    Does anyone know how you would go about formatting a column of data in a bound MSHflexGrid to display a $000.00 format?

    I have a bound MSHFlexGrid to an ado object, with an Access 97 database on the back end. I am displaying one column in the FlexGrid which contains a "monetary" value. I've tried using a text datatype for this field in Access, and defining an input mask property to store the values for this field in a $000.00 format. I've also tried changing the data type in Access to Currency, although I would prefer to store the value as text only. Neither of these approaches work, the column of data is displayed in the MSHFlexGrid as just a line of numbers (23455) with no decimal point and no preceeding $.

    Any advice or ideas would be greatly appreciated!!!!

    chaseltine

  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: formatting data in MSHFlexGrid

    You could try something like :


    Dim sValue as string
    Dim lYourColumnNumber as Long

    lYourColumnNumber = 1

    With MSHFlexGrid1
    .Redraw = false ' makes it about 10x faster !
    for lCount = .FixedRows to .Rows - 1
    sValue = MSHFlexGrid1.TextMatrix(lCount, lYourColumnNumber)
    sValue = Format$(sValue, "$###,###,###.##")
    MSHFlexGrid1.TextMatrix(lCount, lYourColumnNumber) = sValue
    next
    .ColAlignment(lYourColumnNumber) = flexAlignRightCenter
    .Redraw = true ' dont forget to do this !
    End With





    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  3. #3
    Join Date
    Dec 1999
    Location
    Texas
    Posts
    6

    Re: formatting data in MSHFlexGrid

    Chris,

    Thank you!!! Now that I see the code, I'm embarrassed to admit that I wasn't able to figure out how to do it myself. But I guess this close to the holidays, with one last bug fix to make before I can take vacation, I'm too burned out to even think straight.

    Have a Merry Christmas, and a Safe and Happy New Year.


    chaseltine

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

Featured