Hi, I have a treeview in my application and a righthand click on a node should have the same behavior as a lefthand mouseclick. For the lefthand mouseclick I use the eventhandler private void treeViewServer_AfterSelect(object sender, TreeViewEventArgs e) { // my code... }
The righthand click should call the same handler. But the eventhandler "click" of the treeview private void treeViewServer_Click(object sender, EventArgs e) { // some code... }
provides not the TreeViewEventArgs of the "AfterSelect" Some ideas? Thanx in advance Erik
Schmullus
Posts
-
Righthand mouse-click to a tree-view should act like a lefthand mouse-click -
Single intanceHi, my you use an static variable within the class that counts the instances.
namespace ConsoleApplication1 { class TestClass { // static variable public static int instanceCount = 0; // Constructor public TestClass() { instanceCount++; } // Some code // ... } class Program { static void Main(string[] args) { TestClass myTestClass1 = new TestClass(); TestClass myTestClass2 = new TestClass(); Console.WriteLine(TestClass.instanceCount); Console.ReadLine(); } } }
You can use the variable 'instanceCount' to restrict the instance generation. Is it that what you're looking for? Regards Erik -
Change ToolTip-FontHi, I try to find a solution for changing the font of a tooltip. I can find no method or property. Any idea? Thanx in advance! Erik
-
Remove ToolTip from a special controlHi, normally, this should work:
private void textBox1_TextChanged(object sender, EventArgs e) { toolTip1.SetToolTip(pictureBox1, textBox1.Text); //toolTip1.RemoveAll(); }
I created a picturebox named 'pictureBox1' and placed the above code within the text-change eventhandler of my textbox 'textBox1'. Anytime I changed the text the tooltip will be updated. There are no multiple tooltips on the picturebox. Maybe try the method RemoveAll() of toolTip1. Regards Erik -
How can I have access to an arraylistThanks a lot for this detailed information!!
-
How can I have access to an arraylistThis works perfect! Thanks a lot:-D
-
How can I have access to an arraylistHi, I tried MessageBox.Show((ServerInfo)(myServerArrayList[0]).strServerName); but it won't work:confused: 'Object has no definition for strServerName' Erik
-
Context menu on a TreeViewHi, have a look to my example: I created a windows-application with a form and one 'TreeView'-component named treeView1 in my code. The only code is written within the Load-event of the form:
private void Form1_Load(object sender, EventArgs e) { ContextMenu myRootContextMenu = new ContextMenu(); myRootContextMenu.MenuItems.Add("Edit Root"); ContextMenu myChild1ContextMenu = new ContextMenu(); myChild1ContextMenu.MenuItems.Add("Edit Child 1"); ContextMenu myChild2ContextMenu = new ContextMenu(); myChild2ContextMenu.MenuItems.Add("Edit Child 2"); **TreeNode rootTreeNode = new TreeNode("Root");** rootTreeNode.ContextMenu = myRootContextMenu; rootTreeNode.Nodes.Add("First Node"); rootTreeNode.Nodes[0].ContextMenu = myChild1ContextMenu; rootTreeNode.Nodes.Add("Second Node"); rootTreeNode.Nodes[1].ContextMenu = myChild2ContextMenu; treeView1.Nodes.Add(rootTreeNode); }
I created one root treenode 'rootTreeNode'TreeNode rootTreeNode = new TreeNode("Root");
and added two child nodes:rootTreeNode.Nodes.Add("First Node"); rootTreeNode.Nodes.Add("Second Node");
After that, I added this treenode to the TreeView 'treeView1' of the Form.treeView1.Nodes.Add(rootTreeNode);
Now we come to the context-menues: I created one root context-menu, and gave it a descriptionContextMenu myRootContextMenu = new ContextMenu(); myRootContextMenu.MenuItems.Add("Edit Root");
and with the property 'ContextMenu' of the rootTreeNoderootTreeNode.ContextMenu = myRootContextMenu;
I made the assignment. The context-menues for the child nodes areContextMenu myChild1ContextMenu = new ContextMenu(); myChild1ContextMenu.MenuItems.Add("Edit Child 1"); ContextMenu myChild2ContextMenu = new ContextMenu(); myChild2ContextMenu.MenuItems.Add("Edit Child 2");
and assigned in the same way. Hope this helps a little bit Regards Erik -
How can I have access to an arraylistHi there, I have the following problem: I want to add a variable 'myServerInfo' to an arraylist. This variable is of the datatyp 'ServerInfo' (public class). I can add this variable without any problems to the arraylist with the command:
myServerArrayList.Add(myServerInfo);
But how can I have access to this through the arraylist? If I type in the following commandline, Intellisense will not provide me the necessary information:Console.WriteLine(myServerArrayList[0].???
I thought I can type in:Console.WriteLine(myServerArrayList[0].strServerName); Console.WriteLine(myServerArrayList[0].strServerIP); Console.WriteLine(myServerArrayList[0].strServerNetMask);
My complete code for this example is like:using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace ConsoleApplication1 { public class ServerInfo { public string strServerName; public string strServerIP; public string strServerNetMask; } class Program { static void Main(string[] args) { ArrayList myServerArrayList = new ArrayList(); ServerInfo myServerInfo = new ServerInfo(); myServerInfo.strServerName = "Server 1"; myServerInfo.strServerIP = "192.168.0.1"; myServerInfo.strServerNetMask = "255.255.255.0"; // Add to ArrayList myServerArrayList.Add(myServerInfo); Console.WriteLine(myServerArrayList[0].??? } } }
If anybody gives me a hint, I can go on with my project.:) Thanks in advance Erik