Results 1 to 6 of 6

Thread: MS Flexgrid question

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    34

    Post

    How can I set a specific column width in my flexgrid? In addition, is it possible to click on a row, then click a command button and open a new form and display that particular record?

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    intCol = MSFlexGrid1.col
    intRow = MSFlexGrid1.row

    Those would give you the col and row of the cell you cliked on. In reverse:

    MSFlexGrid1.row = intRow
    MSFlexGrid1.col = intCol

    You can use these to cycle through the grid if you want or retrieve the info from a database.

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Use the ColWidth() Property to specify the Width of a Specific Cell, ie.

    MSFlexGrid1.ColWidth(0) = 500

    You can just Reference the MSFlexGrid1 Object on Form1 from Form2, ie.

    Add a Textbox called txtField to Form2 and set its Index Property to Zero..

    In Form1..
    Code:
    Private Sub Form_Load()
        Dim iIndex As Integer
        With MSFlexGrid1
            .SelectionMode = flexSelectionByRow
            .FocusRect = flexFocusNone
            .Cols = 4
            .Rows = 5
            .FixedCols = 0
            .FixedRows = 0
            For iIndex = 0 To 19
                .TextArray(iIndex) = Rnd * 100
            Next
        End With
    End Sub
    
    Private Sub Command1_Click()
        Form2.Show vbModal
    End Sub
    In Form2..
    Code:
    Private Sub Form_Load()
        Dim iField As Integer
        
        With Form1.MSFlexGrid1
            For iField = 0 To .Cols - 1
                If iField Then Load txtField(iField)
                txtField(iField).Move txtField(0).Left, txtField(0).Top + (iField * txtField(0).Height)
                txtField(iField) = .TextMatrix(.Row, iField)
                txtField(iField).Visible = True
            Next
        End With
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    34

    Post

    Hi Aaron,

    When I put the code in as you've described above, I get error " Compile Error: Wrong number of arguments or invalid property assignmen." Any suggestions? Thanks.

  5. #5
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Works fine when I cut and Paste it..

    Did you Add a 2nd Form, with a Textbox on it called txtField with an Index Value of 0(Zero)?

    If so, where are you getting the Error?

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


  6. #6

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    34

    Post

    Allright, here's the situation. On form1 I click a row, then I click command2, the error then occurs on form2 at line: txtField(iDate).Move txtField(0).Left, txtField(0).Top(iDate * txtField(0).Height)....Top is highlighted...also, when I click on the button, flexgrid1 on form1 changes to several rows with random numbers!! Any suggestions?

    Thanks,
    Dave

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