How do I create a form with no border
Use the Form.FormBorderStyle property to control a form’s border. public void InitMyForm() { // Adds a label to the form. Label label1 = new Label(); label1.Location = new System.Drawing.Point(80,80); label1.Name = ‘label1’; label1.Size = new System.Drawing.Size(132,80); label1.Text = ‘Start Position Information’; this.Controls.Add(label1); // Changes the border to Fixed3D. FormBorderStyle = FormBorderStyle.Fixed3D; // Displays the border information. label1.Text = ‘The border is ‘ + FormBorderStyle; } (From the .NET Framework SDK documentation)
In the property browser for a custom control, how do I disable a property initially, but enable it later based on some other property changing
Implement ICustomTypeDescriptor, and provide your own PropertyDescriptor for that property that changes it’s return value for IsReadOnly.
What is the purpose of the [STA Thread] attribute for the Main method of a C# program
That marks the thread as being ‘Single Thread Apartment’ which means any multiple threaded calls need to be marshaled over to that thread before they are called. That’s there because Windows Forms uses some OLE calls (Clipboard for example), which must be made from the thread that initialized OLE. (from [email protected] on microsoft.public.dotnet.framework.windowsforms)
How do I send a EM_XXXX message to a textbox to get some value such as line index in C#
There is a protected SendMessage call you can use for this purpose, so you have to derive from TextBox. public MyTextBox : TextBox { private const int EM_XXXX = 0x1234; public int LineIndex { get { return base.SendMessage(EM_XXXX, 0, 0); } } } (from [email protected] on microsoft.public.dotnet.framework.windowsforms)
How can I detect if the user clicks into another window from my modal dialog
Use the Form.Deactivate event: this.Deactivate += new EventHandle(OnDeactivate); //… private void OnDeactivate(object s, EventArgs e) { this.Close(); } (from [email protected] on microsoft.public.dotnet.framework.windowsforms)