How do I compile unsafe code in VS.NET
Click ‘Project | Properties’ from the menus. Select ‘Configuration Properties’ folder and the ‘Build’ item under that. Switch ‘Allow unsafe code blocks’ from ‘False’ to ‘True’. (from Ryan LaNeve on microsoft.public.dotnet.framework.windowsforms)
How do I convert a string to an double or int?
One way is to use static members of the Convert class in the System namespace. textBoxResult.Text = Convert.ToString(Convert.ToDouble(textBox1.Text) * Convert.ToDouble(textBox2.Text));
How can I have the control designer create the custom editor by calling the constructor with the additional parameters rather than the default constructor
You can do this by creating the editor yourself rather than allowing TypeDescriptor to do it: 1) Shadow the property you care about in your designer… protected override void PreFilterProperties(IDictionaryProperties props) { PropertyDescriptor basePD = props[‘MyProperty’]; props[‘MyProperty’] = new EditorPropertyDescriptor(basePD); } 2) Create a property descriptor that ‘wraps’ the original descriptor private class EditorPropertyDescriptor : PropertyDescriptor { private PropertyDescriptor basePD; public EditorPropertyDescriptor(PropertyDescriptor base) { this.basePD = base; } // now, for each property and method, just delegate to the base… public override TypeConverter Converter { get { return basePD.Converter; } } public override bool CanResetValue(object comp) { return basePD.CanResetValue(comp); } // and finally, implement GetEditor to create your special one… 3) create your editor by hand when it’s asked for public override object GetEditor(Type editorBaseType) { if (editorBaseType == typeof(UITypeEditor)) { return new MyEditor(Param1, param2, param3); } return basePD.GetEditor(editorBaseType); } } (from [email protected] on microsoft.public.dotnet.framework.windowsforms)
How can I catch the mouse being over a control
Add a handler for the control’s MouseMove event. This will be hit as the mouse moves over the control’s Bounds rectangle.
How do I get a mouse cursor position in my control’s client coordinates
Use the Position property of the Cursor class found in the System.Windows.Forms namespace. Here is code that will flag whether the mouse is over button1. Point ptCursor = Cursor.Position; ptCursor = PointToClient(ptCursor); if( button1.Bounds.Contains(ptCursor) ) { //mouse over button1 //…. } else { //mouse not over button1 //…. }