Can I generate UML diagrams from C# code?
There are several commercial products that support this. Take a look at Metamill and WithClass
How do I determine the DataGridTableStyle MappingName that should used for a DataGrid to make sure the grid uses my tablestyle
The DataGrid looks for a DataGridTableStyle.MappingName that is the type name of its datasource. So, depending upon what datasource you are using, this may be ‘ArrayList’ for a ArrayList, ‘MyCollection[]’ for an array of MyCollection objects, or ‘MyTableName’ for a datatable, or whatever. Here is a code snippet provide by NoiseEHC on the microsoft.public.dotnet.framework.windowsforms.controls newsgroup that you can use to see exactly what mappingname is required for your datasource. [C#] //usage ShowMappingName(dataGrid1.DataSource); //implementation void ShowMappingName(object src) { IList list = null; Type type = null; if(src is Array) { type = src.GetType(); list = src as IList; } else { if(src is IListSource) src = (src as IListSource).GetList(); if(src is IList) { type = src.GetType(); list = src as IList; } else { MessageBox.Show(‘error’); return; } } if(list is ITypedList) MessageBox.Show((list as ITypedList).GetListName(null)); else MessageBox.Show(type.Name); } [VB.NET] Private Sub ShowMappingName(ByVal src As Object) Dim list As IList = Nothing Dim t As Type = Nothing If TypeOf (src) Is Array Then t = src.GetType() list = CType(src, IList) Else If TypeOf src Is IListSource Then src = CType(src, IListSource).GetList() End If If TypeOf src Is IList Then t = src.GetType() list = CType(src, IList) Else MessageBox.Show(‘Error’) Return End If End If If TypeOf list Is ITypedList Then MessageBox.Show(CType(list, ITypedList).GetListName(Nothing)) Else MessageBox.Show(t.Name) End If End Sub
What is different about working with forms in VB.NET? For example, how can I reference one form from another form
Check out this Microsoft article on working with multiple forms in VB.NET by Duncan Mackenzie.
How can I catch an exception on a program wide basis
You can handle the Application.ThreadException event. See the FrameWork class library for a more detailed sample in both VB and C#. [STAThread] public static void Main() { Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(UnhandledExceptionCatcher); Application.Run(new Form1()); } private static void UnhandledExceptionCatcher(object sender, System.Threading.ThreadExceptionEventArgs e) { Console.WriteLine(‘caught an unhandled exception.’); }
How can I get a tooltip to vary from node to node in my treeview
Try using a MouseMove event handler and checking to see if you have moved to a new node, and if so, set a new tiptext. [C#] private int oldNodeIndex = -1; private ToolTip toolTip1; private void Form1_Load(object sender, System.EventArgs e) { this.toolTip1 = new System.Windows.Forms.ToolTip(); this.toolTip1.InitialDelay = 300; //half a second delay this.toolTip1.ReshowDelay = 0; } private void treeView1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { TreeNode tn = this.treeView1.GetNodeAt(e.X, e.Y); if(tn != null) { int currentNodeIndex = tn.Index; if(currentNodeIndex != oldNodeIndex) { oldNodeIndex = currentNodeIndex; if(this.toolTip1 != null && this.toolTip1.Active) this.toolTip1.Active = false; //turn it off this.toolTip1.SetToolTip(this.treeView1, string.Format(‘tooltip: node {0}’, oldNodeIndex)); this.toolTip1.Active = true; //make it active so it can show } } } [VB.NET] Private oldNodeIndex As Integer = – 1 Private toolTip1 As ToolTip Private Sub Form1_Load(sender As Object, e As System.EventArgs) Me.toolTip1 = New System.Windows.Forms.ToolTip() Me.toolTip1.InitialDelay = 300 ’half a second delay Me.toolTip1.ReshowDelay = 0 End Sub ’Form1_Load Private Sub treeView1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Dim tn As TreeNode = Me.treeView1.GetNodeAt(e.X, e.Y) If Not (tn Is Nothing) Then Dim currentNodeIndex As Integer = tn.Index If currentNodeIndex <> oldNodeIndex Then oldNodeIndex = currentNodeIndex If Not (Me.toolTip1 Is Nothing) And Me.toolTip1.Active Then Me.toolTip1.Active = False ’turn it off End If Me.toolTip1.SetToolTip(Me.treeView1, String.Format(‘tooltip: node {0}’, oldNodeIndex)) Me.toolTip1.Active = True ’make it active so it can show End If End If End Sub ’treeView1_MouseMove