Results 1 to 13 of 13

Thread: [RESOLVED] MSFlexGrid1 and combo box

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] MSFlexGrid1 and combo box

    I have combo box. How I can show the number of row in the data grid base on the number of record selected on combo box?
    Last edited by matrik02; Nov 19th, 2007 at 12:00 PM.

  2. #2
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Datagrid and combo box

    Does this Combo box hold the Record Number or any Value from the DB itself.
    If its the Record Number, try like Rs.Move(recNumber).

    If its a DB Value, then try like Rs.Filter = "MyDBField = " & MyComboVal

    Note : Use of Filter was adviced to be eliminated in the Forum . I cant remember the exact case. So use wuth caution. And it needs the recordset to be loaded with correct records first.

    IIF(Post.Rate > 0 , , )

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Datagrid and combo box

    Filter is fine to use on smaller recordsets. For anything large you would want to modify the query to limit returned results.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Re: Datagrid and combo box

    Quote Originally Posted by RobDog888
    Filter is fine to use on smaller recordsets. For anything large you would want to modify the query to limit returned results.
    @ RobDog888
    Just for my information, what do you consider to be a smaller recordset?
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: MSFlexGrid1 and combo box

    I just use this

    Combo1.AddItem "1"
    Combo1.AddItem "2"
    Combo1.AddItem "3"
    Combo1.AddItem "4"


    Sorry guy. I use MSFlexGrid1

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: MSFlexGrid1 and combo box

    @aikidokid, I would say it would also depend on system resources and location of the db. But probably anything in the 10's of thousands of records and up.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: MSFlexGrid1 and combo box

    Quote Originally Posted by matrik02
    I just use this

    Combo1.AddItem "1"
    Combo1.AddItem "2"
    Combo1.AddItem "3"
    Combo1.AddItem "4"


    Sorry guy. I use MSFlexGrid1
    You can use a loop to add the items with less code.

    Code:
    Dim i As Integer
    For i = 1 To 100
        Combo1.AddItem i
    Next
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Re: MSFlexGrid1 and combo box

    Quote Originally Posted by RobDog888
    @aikidokid, I would say it would also depend on system resources and location of the db. But probably anything in the 10's of thousands of records and up.
    Sorry to hyjack this thread matrik02
    So with a DB like mine with only 100's or records, and on the same hard drive, this wouldn't be a concern.
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: MSFlexGrid1 and combo box

    No, should be quick and fine.

    Some mid to large size apps use massive databases with sizes up in the Gig range.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: MSFlexGrid1 and combo box

    Thank you.

    Code:
    Dim i As Integer
    For i = 1 To 100
        Combo1.AddItem i
    Next

    After that, I want to change the row number in the MSFlexGrid1, when I chose the row number in the combo box during run time.How to do that?

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

    Re: MSFlexGrid1 and combo box

    Use the Row and TopRow properties.

    Code:
    Private Sub Form_Load()
        Dim i As Long
        MSFlexGrid1.Rows = MSFlexGrid1.FixedRows
        For i = 1 To 100
            MSFlexGrid1.AddItem i
            Combo1.AddItem i
        Next i
    End Sub
    
    Private Sub Combo1_Click()
        MSFlexGrid1.Row = Combo1.Text 'Set current row
        MSFlexGrid1.TopRow = MSFlexGrid1.Row 'makes sure row is visible
    End Sub

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: MSFlexGrid1 and combo box

    Actually I would like to set the row number..

    If I choose number two in the combo1..MSFlexGrid1 with have 2 row.


    If I choose number seven in the combo1..MSFlexGrid1 with have seven row

    and so on..

    How to do that?

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

    Re: MSFlexGrid1 and combo box

    Actually I would like to set the row number..
    You mean you want to set the number of rows in the grid.

    MSFlexgrid1.Rows = CLng(Combo1.Text) + MSFlexGrid1.FixedRows

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