Thread: Dynamic Forms

  1. #1
    Registered User
    Join Date
    Jun 2015
    Posts
    8

    Dynamic Forms

    I need to create a form where the buttons and functions of those buttons are populated by a table in a database. As my boss makes his expectations ore clear, I will add to this. Also, this is my first time being the lead programmer on a project, so wish me luck.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    assuming the functions already exist in the code, you can look them up by name, using reflection. You can then easily create buttons programmatically, and add them to your form, hooking them up to event handlers you got from the database.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #3
    Registered User
    Join Date
    Jun 2015
    Posts
    8
    Thank you, this helps. Honestly, I haven't been programming very long and am not ready to be a lead IMO. But I got our last program up and running after the person before me spent over a year trying to do so. Until last December, I had never written in C#. I am still learning the little things about the language.

  4. #4
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Which part of this do you not know how to do? Retrieve information from a database? Dynamically add form elements?
    If you understand what you're doing, you're not learning anything.

  5. #5
    Registered User
    Join Date
    Jun 2015
    Posts
    8
    Just dynamically adding form elements. But, I've got it now. I'm sure I'll e posting more problems. However, if you have any tips on doing this, I know I sort of took the long way around on this one.

  6. #6
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    One easy tip, assuming you're using WinForms, is just to create a static form and then look at the code generated in the *.designer.cs file.

    Unlike some graphical window layout tools, with C#/WinForms, nearly all form configuration and behavior is specified in generated code.

    If what you want is sort of a toolbox, you could use a ToolStrip or similar control, and lay that out on your form normally, then dynamically build its contents. That can be an easy method to dynamically create tools inside a statically laid out control.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GUI and forms
    By gilit2 in forum C++ Programming
    Replies: 7
    Last Post: 02-06-2011, 12:55 AM
  2. C# Forms
    By Xarzu Athanasop in forum C# Programming
    Replies: 2
    Last Post: 01-16-2008, 11:57 AM
  3. Forms
    By gvector1 in forum C# Programming
    Replies: 2
    Last Post: 11-11-2003, 08:43 AM
  4. forms!!!???
    By SuperNewbie in forum C# Programming
    Replies: 6
    Last Post: 08-05-2002, 11:52 PM
  5. Forms
    By Unregistered in forum C# Programming
    Replies: 2
    Last Post: 05-05-2002, 09:17 AM

Tags for this Thread