CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: FkexGrid

  1. #1
    Join Date
    Apr 2001
    Location
    ohio
    Posts
    300

    FkexGrid

    the area in a Flexgrid to put data is small, can i make it bigger??

    Ron



  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: FkexGrid

    if u r talking about column width & row height then

    MSFlexGrid1.ColWidth(Col) = 2000
    MSFlexGrid1.RowHeight(Row) = 100

    where Col & Row is the index of column & row.

    cksiow
    http://vblib.virtualave.net - share our codes



  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: FkexGrid

    ...and you can also let usert resize it with mouse to the width he likes (check for flexresize property)

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: FkexGrid

    You also can make the cell multiline

    Private Declare Function SendMessage Lib "user32" Alias _
    "SendMessageA" _
    (ByVal hwnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    lParam As Any) As Long

    Const EM_GETLINECOUNT = &HBA

    Private Sub Command1_Click()
    Dim ColLoop As Long
    Dim RowLoop As Long

    'Turn off redrawing to avoid flickering
    MSFlexGrid1.Redraw = False

    For ColLoop = 0 To MSFlexGrid1.Cols - 1
    MSFlexGrid1.ColWidth(ColLoop) = 2500

    For RowLoop = 0 To MSFlexGrid1.Rows - 1
    ReSizeCellHeight RowLoop, ColLoop
    Next RowLoop
    Next ColLoop

    'Turn redrawing back on
    MSFlexGrid1.Redraw = True
    End Sub


    Public Sub ReSizeCellHeight(MyRow As Long, MyCol As Long)
    Dim LinesOfText As Long
    Dim HeightOfLine As Long

    'Set MSFlexGrid to appropriate Cell
    MSFlexGrid1.Row = MyRow
    MSFlexGrid1.Col = MyCol

    'Set textbox width to match current width of selected cell
    Text1.Width = MSFlexGrid1.ColWidth(MyCol)

    'Set font info of textbox to match FlexGrid control
    Text1.Font.Name = MSFlexGrid1.Font.Name
    Text1.Font.Size = MSFlexGrid1.Font.Size
    Text1.Font.Bold = MSFlexGrid1.Font.Bold
    Text1.Font.Italic = MSFlexGrid1.Font.Italic
    Text1.Font.Strikethrough = MSFlexGrid1.Font.Strikethrough
    Text1.Font.Underline = MSFlexGrid1.Font.Underline

    'Set font info of form to match FlexGrid control
    Me.Font.Name = MSFlexGrid1.Font.Name
    Me.Font.Size = MSFlexGrid1.Font.Size
    Me.Font.Bold = MSFlexGrid1.Font.Bold
    Me.Font.Italic = MSFlexGrid1.Font.Italic
    Me.Font.Strikethrough = MSFlexGrid1.Font.Strikethrough
    Me.Font.Underline = MSFlexGrid1.Font.Underline

    'Put the text from the selected cell into the textbox
    Text1.Text = MSFlexGrid1.Text

    'Get the height of the text in the textbox
    HeightOfLine = Me.TextHeight(Text1.Text)

    'Call API to determine how many lines of text are in text box
    LinesOfText = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0&, 0&)

    'Check to see if row is not tall enough
    If MSFlexGrid1.RowHeight(MyRow) <= (LinesOfText * HeightOfLine) Then
    'Adjust the RowHeight based on the number of lines in textbox
    MSFlexGrid1.RowHeight(MyRow) = LinesOfText * HeightOfLine
    End If
    End Sub





    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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