Is there a .Net way of deciding whether a string is numeric or not

VB.NET has a IsNumeric method that you can use to recognize a Short, Integer, Long, Decimal or Single numeric type. From C#, you can use try/catch to look for a particular numeric type. //long for a Single Single num; try { num = Single.Parse(someString); } catch (Exception e) { // if this is hit, someString is not a Single }

How can I catch a double-click into a column header cell

You can use the DataGrid’s double-click event and its HitTest method to catch a double click on a header. private void dataGrid1_DoubleClick(object sender, System.EventArgs e) { System.Drawing.Point pt = dataGrid1.PointToClient(Cursor.Position); DataGrid.HitTestInfo hti = dataGrid1.HitTest(pt); if(hti.Type == DataGrid.HitTestType.ColumnHeader) { MessageBox.Show(‘double clicked clicked column header ‘ + hti.Column.ToString()); } }

How do I extract a Bitmap from an icon of a specific size

Icon icoClose; // Initialize this icoClose from the resource (for example). Code omitted. … … … // Now create a new icon off this base icon with the required size (18 X 18) in this case. Icon icoClose18By18 = new Icon(icoClose, 18, 18); // Create a bitmap off this icon. Bitmap bmpClose = icoClose.ToBitmap();

How to access a winapi that has a LPTSTR and maxlen param

[DllImport(‘user32.dll’, CharSet=CharSet.Auto, CallingConvention=CallingConvention.Winapi)] public static extern int GetMenuString(IntPtr hMenu, uint uIDItem, [MarshalAs(UnmanagedType.LPTStr)]string lpString,int maxCount,uint uFlag); //Usage: String caption = new String(’t’, 30);//using a dummy char ‘t’ here. int len = GetMenuString(hsysmenu, commandID, caption, 30, 0));

Why am I getting duplicate trace messages for my trace statements

This is possible if the same listener was added more than once to the Listeners list in Trace. This is possible even if an assembly that you linked do makes an additional entry for the same listener. Perform a check like this before adding a listener. if(Trace.Listeners.Count == 0) { Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); Trace.AutoFlush = true; Trace.Indent(); }