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
My SQL server runs on a non-default port. How can I specify this port in my connection string?
The data source component of your connection string should contain the port right after the IP address (or name). It should be separated from the IP by a comma. data source=192.168.123.1, port number; Take a look at this web site for great information on several connection strings. http://www.connectionstrings.com/
I don’t have SQL Server. Is there any way to run the samples that need SQL server
You can use MSDE, a SQL server compatible database engine that MS makes available for free. You can download and install MSDE from a whole variety of sources. Here is one source. MSDE also comes with Visual Studio.NET / .NET framework SDK. It is available under $(VS Install drive):\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Samples\Setup\msde. You can then run $(VS Install drive):\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Samples\Setup\configsamples.exe to configure the northwind database that the samples use.
Is there a imagemap like control in Windows Forms
There isn’t one out of the box. But check out this codeproject article for a control that provides this functionality. ImageMap control on Codeproject