Results 1 to 22 of 22

Thread: [RESOLVED] Creating a lot of controls take time

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2005
    Posts
    114

    Resolved [RESOLVED] Creating a lot of controls take time

    I have 8 frames as containers, each has several pictureboxes also as containers and inside several textboxes and labels, adding up to about 4500 controls to be created, takes time to start. Is there a way to save the created structure and use it in development environment ?

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Creating a lot of controls take time

    Quote Originally Posted by kiymik View Post
    ... adding up to about 4500 controls to be created...
    That awfully unreasonable, though.
    What is it that you do that requires that many controls create at once?
    Why not creating them only when necessary?
    Another approach could be to reuse controls on your form for different purposes...

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

    Re: Creating a lot of controls take time

    I have to agree with Rhino on this one (in spades). You are trying to work with too many controls to accomplish the mission. Rethink the project and perhaps post what you are trying to accomplish. It sounds like the wrong controls are being applied to get the job done.
    Doctor Ed

  4. #4
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Creating a lot of controls take time

    Thirding RhinoBull. 4500 is like 4400 too many.

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: Creating a lot of controls take time

    If by "Is there a way to save the created structure and use it in development environment" you mean things like what you see in the New Project dialog then yes there is. Place your stripped down template in C:\Program Files\Microsoft Visual Studio\VB98\Template\Projects and from then on it will show up in the New tab of that dialog.

    Also you say you have about 4500 controls. Are you talking about one form? If so, there is a limit of 255 and while all members of a control array count as just one control in that count, that's still way too many to have on one form. To find out exactly how many you have, type

    ?frmName.Controls.Count

    in the Immediate Window while the program is in Break mode and hit return.

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: Creating a lot of controls take time

    I suspect the amount of controls could be reduced significantly if you use different ones (eg: perhaps a FlexGrid or ListView) rather than the textboxes etc... if you show us a screenshot we can make apt suggestions.

  7. #7
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: Creating a lot of controls take time

    4500 controls That is absolutely absurd!

    Rethink your design.
    VB.NET MVP 2008 - Present

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2005
    Posts
    114

    Re: Creating a lot of controls take time

    Thank you for comments.
    My project is a table tennis tournament table. It has the player names, competition results, points etc. Each of them are written in different textboxes (they are indexed, so number of individual names don't exceed 256 on one form). The textboxes have different colors for easier entry. Up to 128 players it was acceptably slow, but for 256 players it appeared too slow .

    Attached is one page of the table (there are 7 more created and waiting to be selected). Each small box is a textbox. Since all data has to be written on all boxes I have to create all at once. I may use flexgrid per group, it will reduce number of controls a lot.
    Attached Images Attached Images  

  9. #9

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jan 2005
    Posts
    114

    Re: Creating a lot of controls take time

    Form has 4921 controls
    Using flexgrid will reduce this number by about 4000, it's a great discount, worth to try.

  11. #11

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Jan 2005
    Posts
    114

    Re: Creating a lot of controls take time

    Normally I don't have problems with large number of controls. In one other project I have 3800 controls, it is also starting slow but it doesn't bother. In tournament program these type of up to 20 tables will be opened simultaneously, during competition a slow running program will not be comfortable. 100 is quite a small number for me

  13. #13
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Creating a lot of controls take time

    Quote Originally Posted by kiymik View Post
    Thank you for comments.
    My project is a table tennis tournament table. It has the player names, competition results, points etc. Each of them are written in different textboxes (they are indexed, so number of individual names don't exceed 256 on one form). The textboxes have different colors for easier entry. Up to 128 players it was acceptably slow, but for 256 players it appeared too slow .

    Attached is one page of the table (there are 7 more created and waiting to be selected). Each small box is a textbox. Since all data has to be written on all boxes I have to create all at once. I may use flexgrid per group, it will reduce number of controls a lot.
    I'd just use a picturebox and manually draw the colored boxes and data as needed. Then all you need is 1 picturebox plus however many checkboxes instead of the 3500 or however many controls there are comprising your tables.

  14. #14

  15. #15
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: Creating a lot of controls take time

    The way I see it, the screen you showed only needs about 20 controls - and 11 of those are the top row.

    I would use one FlexGrid for each group (probably in an array), and use one hidden textbox for data entry for all of the grids.


    I have assumed the checkboxes don't really need to be checkboxes (ie: are not used for any kind of user interaction), and only there to show 'not apt' - as the number above them is always the same as the number to the left.

  16. #16
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Creating a lot of controls take time

    Quote Originally Posted by kiymik View Post
    Attached is one page of the table (there are 7 more created and waiting to be selected). ..... I may use flexgrid per group, it will reduce number of controls a lot.
    I would propose that you use 1 FG for ALL 8 groups (ie, one FG for
    group A thru group H). In case you were aware of it, you can "format"
    individual cells to your heart's desire (font, fontsize, fontbold, backcolor,
    forecolor, etc). So, since you propose to have 8 pages, you would
    "need" only 8 FGs, not 921 (approx, per your post #10).

    Indeed, you could possibly do it ALL 8 pages with only 1 FG. Since you
    can only see one FG at a time on your screen (my assumption, tell me
    if I'm wrong), you could "repopulate" the FG "on demand". This would
    presume that your "data" is maintained in an array, and depending on
    which page you are looking at, the solo FG would be repopulated from
    the array for THAT page.

    Does this seem helpful?

    Spoo

  17. #17
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: Creating a lot of controls take time

    Quote Originally Posted by Spoo View Post
    ...Indeed, you could possibly do it ALL 8 pages with only 1 FG. Since you
    can only see one FG at a time on your screen (my assumption, tell me
    if I'm wrong), you could "repopulate" the FG "on demand". This would
    presume that your "data" is maintained in an array, and depending on
    which page you are looking at, the solo FG would be repopulated from
    the array for THAT page.

    Does this seem helpful?

    Spoo
    That's basically what I was suggesting although you spelled it out.

  18. #18
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Creating a lot of controls take time

    Marty

    My apologies. In my haste, I hit the Submit button before
    fully reading your post and thereafter giving you credit for
    the idea.

    Spoo

  19. #19
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: Creating a lot of controls take time

    Quote Originally Posted by Spoo View Post
    Marty

    My apologies. In my haste, I hit the Submit button before
    fully reading your post and thereafter giving you credit for
    the idea.

    Spoo
    I'm not concerned with getting credit but rather it was my way of pointing out to kiymik that more than one of us thinks that might be the way to proceed.

  20. #20

    Thread Starter
    Lively Member
    Join Date
    Jan 2005
    Posts
    114

    Re: Creating a lot of controls take time

    As Spoo says, all groups in one flexgrid, display only the portion I want to see on the form. Yes, it is also more flexible to trace with a scrollbar, not limited to see strictly defined group groups (i.e. I can display groups 1 thru 8 on one page, then 3 thru 10, etc.). All my datas are in arrays, it will not be hard to put them on desired cells.

  21. #21
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: Creating a lot of controls take time

    Quote Originally Posted by kiymik View Post
    As Spoo says, all groups in one flexgrid, display only the portion I want to see on the form. Yes, it is also more flexible to trace with a scrollbar, not limited to see strictly defined group groups (i.e. I can display groups 1 thru 8 on one page, then 3 thru 10, etc.). All my datas are in arrays, it will not be hard to put them on desired cells.
    If you want to you could use just one array. For example...

    Code:
    Option Explicit
    Private Type MyType_Type
        intSomeCount As Integer
        strName As String
        dteDate As Date
    End Type
    Private typMyType() As MyType_Type
    
    Private Sub Form_Load()
    
        ReDim typMyType(99) As MyType_Type
        
        typMyType(0).intSomeCount = 5
        typMyType(0).strName = "Marty"
        typMyType(0).dteDate = "02/12/2010"
        
    End Sub

  22. #22

    Thread Starter
    Lively Member
    Join Date
    Jan 2005
    Posts
    114

    Re: Creating a lot of controls take time

    Using Type will be easier to handle the datas, it is pity that I started with a quite simple program and variable construction, I didn't switch to Type's while the program capacity was growing. Now I have to redesign the structure when both grids and variable constructions are changed. Anyway, this conversation helped me a lot, thanks to you all.

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