Windows forms in c#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Venkadesan
    New Member
    • Aug 2008
    • 7

    Windows forms in c#

    Hai,

    I have one string array which contains all the names of the forms in my MDI, I need to create an instance using that name, How can i convert the string(Form Name) into form. Help me.

    Cheers,
    Venkat
  • cloud255
    Recognized Expert Contributor
    • Jun 2008
    • 427

    #2
    I'm not sure what you're asking.

    But a string cannot become a form.

    If you want to use the string as the name of the form its not too complicated.

    You need to create the form at runtime and then assign an value to the name property. You do this in a loop using each of the strings in your array as the form name.

    but i'm not sure what you are trying to do, could you clarify your quesstion a bit more please.

    Comment

    • Venkadesan
      New Member
      • Aug 2008
      • 7

      #3
      Hai Thank u for ur reply,

      Actually i am trying to do preference settings for my project. For that i have used one ini file which stores the loaded forms(Section) and thier bounds and back color(keys). When i opened a application next time the the bounds of the forms will
      be as like as when it was closed. So i load the form using that ini file (which has form name) and thier properties. Are u clear now....

      Cheers,
      Venkat

      Comment

      • cloud255
        Recognized Expert Contributor
        • Jun 2008
        • 427

        #4
        Ok,

        so you still have to create the froms at runtime. Then assing the right value to each property from your INI file. So make a loop which loops through all the data in the INI (you must have it seperated in some way like one per line or some sort of identifier in the file) and then create a new from and assign the properties to the form.

        to give a value for the name of a form you just address the "Name" property.

        When you want to write to your INI file after running the application you can loop through all the children in the MDI parent and adress them by name:

        Code:
        foreach (Form frm in this.MdiChildren)
                    {
                        MessageBox.Show(frm.Name);
                    }
        Hope this helps.

        Comment

        • Venkadesan
          New Member
          • Aug 2008
          • 7

          #5
          Originally posted by cloud255
          Ok,

          so you still have to create the froms at runtime. Then assing the right value to each property from your INI file. So make a loop which loops through all the data in the INI (you must have it seperated in some way like one per line or some sort of identifier in the file) and then create a new from and assign the properties to the form.

          to give a value for the name of a form you just address the "Name" property.

          When you want to write to your INI file after running the application you can loop through all the children in the MDI parent and adress them by name:

          Code:
          foreach (Form frm in this.MdiChildren)
                      {
                          MessageBox.Show(frm.Name);
                      }
          Hope this helps.

          Hi,

          Thanks for your Reply..

          Comment

          Working...