Dynamic Windows Form building

Discussion in 'C#' started by htetnaing, Oct 3, 2010.

  1. htetnaing

    htetnaing New Member

    Joined:
    Oct 3, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi everyone,

    I am thinking of doing something like this but I am not sure it can be done or not. Normally, if i write a program (Windows Form) I drag and drop what button and textboxes are necessary on the form then do necessary procedures and actions. What I am thinking now is, is there anyway to build a window form dynamically using some setting from a file ? I have no idea how to do it. Let's say if I have something like "button 3" then on my window form, it has 3 buttons on it. So, if i change that text file to "button 4" then on my window form, it has 4 buttons on it. If possible, I would like to know how to assign event to those button. I am not sure whether it's feasible or not but please I am looking forward to hearing other experts ideas here. Thanks all.
     
  2. Love.NET

    Love.NET New Member

    Joined:
    Nov 20, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    http://sites.google.com/site/esubstance
    I think it's feasible.
    You can create a file including informations on the controls, elements (what are they ?- buttons, checkboxes..., their properties, events) with a certain format (to help you get these informations at runtime).
    Then, for example you have a button that when clicking on, it will load all controls, elements and concerning settings and show them on your form. First, after clicking on that button, it will read the file you created, according to the rule when formating that file you can get exactly what you wrote in that file. Then you can create new controls basing on the informations you've gotten.
    I think it's not easy at all, but that's my idea. And I think it's very worthy to try. Thank you for the good question. I'll also try it by myself. If succeed, I'll send you my codes.
    Thanks !
     
  3. servalsoft

    servalsoft New Member

    Joined:
    Apr 17, 2010
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    It is actually possible to do that, I have created button before at runtime and added them to my form, but you have to put it all first on paper for the info you would like to see persistant.... and then as L.net mentioned, you just read from the file, and fill in the gaps. what you dont put will be set with the default values.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice