Results 1 to 12 of 12

Thread: Populating data in MSFlexgrid..(need help)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    Philippines
    Posts
    139

    Populating data in MSFlexgrid..(need help)

    how to load data in MSflexgrid? the data is not from database:.. like for example, i want to populate first name, last name and address.. how to code this at runtime together with its column name?

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Populating data in MSFlexgrid..(need help)

    Quote Originally Posted by joebhoy
    how to load data in MSflexgrid? the data is not from database:.. like for example, i want to populate first name, last name and address.. how to code this at runtime together with its column name?
    Code:
    Sub LoadMSFlexGrid()
        Dim iRow As Integer
        Dim iCol As Integer
        With MSFlexGrid1
            .Rows = 4      ' Including Fixed Row
            .Cols = 4      ' Including FixedCol
            .FixedCols = 1
            .FixedRows = 1
          
            'Generate Column Names
            For iCol = 1 To 3
                'Code here to give appropriate names
                'I am just giving numbers as names
                .TextMatrix(0, iCol) = iCol
            Next
          
            'Generate Row Names
            For iRow = 1 To 3
                'Code here to give appropriate names
                'I am just giving numbers as names
                .TextMatrix(iRow, 0) = iRow
            Next
          
            'The data is loaded here
            For iRow = 1 To 3
                For iCol = 1 To 3
                    'Replace 0 with the data
                    .TextMatrix(iRow, iCol) = 0
                Next
            Next
        End With
    End Sub
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    Philippines
    Posts
    139

    Re: Populating data in MSFlexgrid..(need help)

    Fullrowselect, is it possible?

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Populating data in MSFlexgrid..(need help)

    what do you mean by Fullrowselect? for inputting data?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    Philippines
    Posts
    139

    Re: Populating data in MSFlexgrid..(need help)

    i mean, when i click a certain row, it would select the full row..

  6. #6
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: Populating data in MSFlexgrid..(need help)

    Quote Originally Posted by joebhoy
    i mean, when i click a certain row, it would select the full row..
    Code:
    Private Sub MSFlexGrid1_Click()
    With MSFlexGrid1
        For I = 1 To .Cols - 1
            .ColSel = I
        Next
    End With
    End Sub
    Doctor Ed

  7. #7
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Populating data in MSFlexgrid..(need help)

    Quote Originally Posted by joebhoy
    i mean, when i click a certain row, it would select the full row..
    To do this programatically, Read more on the property .Rowsel
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    Philippines
    Posts
    139

    Re: Populating data in MSFlexgrid..(need help)

    thanx,, got it.. want to ask another Q:
    how can i get a value in specific column or row?

  9. #9
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: Populating data in MSFlexgrid..(need help)

    Quote Originally Posted by joebhoy
    thanx,, got it.. want to ask another Q:
    how can i get a value in specific column or row?
    Before you add a value to the grid, store that in an array. The grid does not generate its own values, you do. If a user later clicks on a cell and you want the value in the cell to be returned, the row and column then determine the variable and array position.
    Doctor Ed

  10. #10
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Populating data in MSFlexgrid..(need help)

    how can i get a value in specific column or row?
    You don't need to store the grid's data in an external array. Use the grid's TextMatrix property to get/set the value of a single cell. Simply pass it the applicable row/col pair.

    MSFlexGrid1.TextMatrix(5,4) = "Hello World"
    strCellValue = MSFlexGrid1.TextMatrix(5,4)

    Also, set the SelectionMode property to flexSelectByRow to get "full row select". Note that it only works when the navigates through the grid with the keyboard or mouse. If you set the current Row or Col in code you must re-select the entire row in code, eg.

    Code:
    with MSFlexGrid1
        .Col = .FixedCols
        .ColSel = .Cols - 1
    end with

  11. #11
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Populating data in MSFlexgrid..(need help)

    Another way is to use the clip property
    Code:
    Private Sub cmdSaveGrid_Click()
        Dim MyFile As String
        Dim F
        Dim Data As String    
        F = FreeFile
        
        With Grid
           .Row = 1
           .Col = 1
           .ColSel = .Cols - 3 'change for your data
           .RowSel = .Rows - 1
           Data = .Clip
           .Row = 0
           .Col = 0
        End With
        MyFile = App.Path & "\Grid.dat"
       
        On Error Resume Next ' if file doesn't exist, create it
        
        Open MyFile For Binary As #F
         Put #F, 1, Data
        Close #F
       
    
    End Sub
    
    'get it back
    
    Private Sub cmdLoadGrid_Click()
        Dim MyFile As String
        Dim F
        Dim Data As String * 550 'adjust this   
        F = FreeFile
    
        cmdClearQuickGrid_Click
        MyFile = App.Path & "\Grid.dat"
       On Error Resume Next 
        Open MyFile For Binary As #F
         Get #F, 1, Data
        Close #F
       
       
        With GridQuick
           .Row = 1
           .Col = 1
           .ColSel = .Cols - 3
           .RowSel = .Rows - 1
           .Clip  = Trim(Data)
           .Row = 0
           .Col = 0
        End With
       
      
    End Sub
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    Philippines
    Posts
    139

    Re: Populating data in MSFlexgrid..(need help)

    thanx... this would greatly helps... :-)

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