Open form
-
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
-
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
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)));
-
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)));
-
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
-
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();
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
-
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
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
-
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