
March 1st, 2005, 05:44 PM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 6
Time spent in forums: 15 m 43 sec
Reputation Power: 0
|
|
|
c# newbie questions
Hey,
I have a few questions to ask about various aspects of windows forms with c#.
First off, how do I make a TextBox (or RichTextBox) expand to the size of the form? i.e. I always want the textbox to take up the whole form. I know there is a command for that, but I cannot find it.
Second, how can I open the file browser? I read the MSDN snippert on it, but it won't work. I want to open the file browser when one of my menu items is clicked, and load the selected file into the text box.
Here is the code that I have so far.
Code:
using System;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
class nPad : Form {
public nPad() {
Text = "nPad";
BackColor = Color.LightGray;
Size = new Size(300, 300);
Location = new Point(20, 20);
// Textbox
RichTextBox tbox = new RichTextBox();
tbox.Size = new Size(290,200);
tbox.SelectionFont = new Font("Verdana", 12);
Controls.Add(tbox);
// Menu
MainMenu mnu = new MainMenu();
this.Menu = mnu;
MenuItem mnuFile = new MenuItem("&File");
MenuItem mnuQuit = new MenuItem("&Quit");
mnu.MenuItems.Add(mnuFile);
mnuFile.MenuItems.Add(mnuQuit);
mnuQuit.Click += new EventHandler(mnuQuit_Click);
}
public void mnuQuit_Click(object obj, EventArgs ea) {
Application.Exit();
}
public static void Main() {
Application.Run(new nPad());
}
}
I know what "public" means before a code section, but what does "static" and "void" mean/do? And what exactly does "object obj" and "EventArghs ea" do?
Thanks!
|