How can I get all IP addresses for my local machine
[C#] string s =”; System.Net.IPAddress[] addressList = Dns.GetHostByName(Dns.GetHostName()).AddressList; for (int i = 0; i < addressList.Length; i ++) { s += addressList[i].ToString() + ‘\n’; } textBox1.Text = s; [VB.NET] Dim s As String = ” Dim addressList As System.Net.IPAddress() = Dns.GetHostByName(Dns.GetHostName()).AddressList Dim i As Integer For i = 0 To addressList.Length – 1 s += addressList(i).ToString() + ControlChars.Lf Next i textBox1.Text = s
How can I determine the node level of a node in my treeview
Here is a code snippet suggested by Mattias Sjögren on the microsoft.public.dotnet.languages.csharp newsgroup. [C#] public int NodeLevel(TreeNode node) { int level = 0; while ((node = node.Parent) != null) level++; return level; } [VB.NET] Public Sub NodateLevel(ByVal node as TreeNode) As Integer Dim level as Integer = 0 While Not node Is Nothing node = node.Parent level = level + 1 End While End Sub
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.