How can I get text from a column header in a MouseUp event
private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { System.Drawing.Point pt = new Point(e.X, e.Y); DataGrid.HitTestInfo hti = dataGrid1.HitTest(pt); if(hti.Type == DataGrid.HitTestType.Cell) { MessageBox.Show(dataGrid1[hti.Row, hti.Column].ToString()); } else if(hti.Type == DataGrid.HitTestType.ColumnHeader) { MessageBox.Show(((DataView) DataGrid1.DataSource).Table.Columns[hti.Column].ToString()); } }
How can I direct debug output to a text file
You need to add a Trace Listener to your code. Below is sample code that adds a TextWriterTraceListener (and don’t forget the Flush before you terminate). For more information on tracing in general, look for the topic ‘Tracing Code in an Application’ in your online .NET documentation. //set up the listener… System.IO.FileStream myTraceLog = new System.IO.FileStream(@’C:\myTraceLog.txt’, System.IO.FileMode.OpenOrCreate); TextWriterTraceListener myListener = new TextWriterTraceListener(myTraceLog); ………. //output to the instance of your listener myListener.WriteLine( ‘This is some good stuff’); ……….. //flush any open output before termination… maybe in an override of your form’s OnClosed myListener.Flush();
How can I determine if a string is a valid date
You can use the static DateTime.Parse or DateTime.ParseExact and catch any exceptions. System.DateTime myDateTime; bool isValid = true; try { myDateTime = System.DateTime.Parse(strMyDateTime); } catch (Exception e) { isValid = false; }
How do I use VS to add an override for a virtual member of a baseclass
In the ClassView window, expand the base class under your derived class. Then right-click the desired method, and select Add.
How can I reset the OnMouseHover timer so that it will fire again without the mouse having to leave the client area of a control
In the microsoft.public.dotnet.framework.windowsforms newsgroup, T. H. in den Bosch posted the following suggestion with a potential warning: I found out that calling Control.ResetMouseEventArgs() does the trick. This is an undocumented internal method, so I don’t know if calling it has adverse side effects.