Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Open form

Open form

Scheduled Pinned Locked Moved C#
questioncsharplearning
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi , i am actually beginner with C#, so i have a simple question. I Have a form "Form1.cs" and "Form2.cs" so when i press button , in "Form1.cs" , i want simply the Form2 dialog to show up. And one more thing how can i programatically set font of a textBox ?? Regards m0n0 m0n0

    H 1 Reply Last reply
    0
    • L Lost User

      Hi , i am actually beginner with C#, so i have a simple question. I Have a form "Form1.cs" and "Form2.cs" so when i press button , in "Form1.cs" , i want simply the Form2 dialog to show up. And one more thing how can i programatically set font of a textBox ?? Regards m0n0 m0n0

      H Offline
      H Offline
      hooray
      wrote on last edited by
      #2

      1st question: If you want to show a second window you hav 2 option - show it as dialog or as free window here a sample to show it as dialog (the easier way): Form2 f = new Form2(); f.ShowDialog(); 2nd question: you can change the font of a textbox in the following way (this is the visual studio auto generated code if you change it in the designer): this.textBox1.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

      L 1 Reply Last reply
      0
      • H hooray

        1st question: If you want to show a second window you hav 2 option - show it as dialog or as free window here a sample to show it as dialog (the easier way): Form2 f = new Form2(); f.ShowDialog(); 2nd question: you can change the font of a textbox in the following way (this is the visual studio auto generated code if you change it in the designer): this.textBox1.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Thanks hooray for attention. Could you help me with one more problem , i want to save to text file(*.txt) what textBox contains Thanks in advance m0n0

        H 1 Reply Last reply
        0
        • L Lost User

          Thanks hooray for attention. Could you help me with one more problem , i want to save to text file(*.txt) what textBox contains Thanks in advance m0n0

          H Offline
          H Offline
          hooray
          wrote on last edited by
          #4

          you just have to open an streamwriter object (in the namespace System.IO) and then write the string to the file. string str = textBox1.Text; StreamWriter sw = new StreamWriter(@"1.txt"); sw.Write(str); sw.Close();

          L 1 Reply Last reply
          0
          • H hooray

            you just have to open an streamwriter object (in the namespace System.IO) and then write the string to the file. string str = textBox1.Text; StreamWriter sw = new StreamWriter(@"1.txt"); sw.Write(str); sw.Close();

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Thanks! i guess @ means that the file will be saved there from where the program is launched? and is there smth like @ but the file will be saved in windows folder.(like regedit has %system%). And i have problems setting oppacity programatically, i do following this.Oppacity = 50; but it does not work , i think it needs smth like Updatedata() ??? Best Regards. m0n0

            H 1 Reply Last reply
            0
            • L Lost User

              Thanks! i guess @ means that the file will be saved there from where the program is launched? and is there smth like @ but the file will be saved in windows folder.(like regedit has %system%). And i have problems setting oppacity programatically, i do following this.Oppacity = 50; but it does not work , i think it needs smth like Updatedata() ??? Best Regards. m0n0

              H Offline
              H Offline
              hooray
              wrote on last edited by
              #6

              the @ means the special chars like '\' will not be interpreted. for example: @"c:\1.txt" == "c:\\1.txt" (for me - I just getting used to use it as standard) The Opacity could not be set to the value of 50. The Opacity is a float value - so if you like to reach 50% opacity you should set it to 0.5

              L 1 Reply Last reply
              0
              • H hooray

                the @ means the special chars like '\' will not be interpreted. for example: @"c:\1.txt" == "c:\\1.txt" (for me - I just getting used to use it as standard) The Opacity could not be set to the value of 50. The Opacity is a float value - so if you like to reach 50% opacity you should set it to 0.5

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Thanks m0n0

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups