473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

C# treeview Forms

9
Is there a way to list opend mdichild forms in treeview so i could open them while i click on treeview nodes with the form name.I allready got the way how i can get the opend mdichild forms to list in treeview, now i need to make a click event so selected node would open the selected form. How can i get that.

Plz help ty.
Mar 14 '08 #1
7 3565
Sick0Fant
121 100+
Is the treeview in the MDI itself?
Mar 14 '08 #2
fadah
9
treeview is in mdicontainer form the parent form.
Mar 14 '08 #3
Sick0Fant
121 100+
Well, since you create the windows in FrameWndProc() upon receiving a NEW_DOCUMENT message, it should be fairly easy to get the handles to those windows, shouldn't it?

EDIT: I'm sorry, I was thinking C++ API.

But... give me some time to think aboutthe .NET solution.
Mar 14 '08 #4
fadah
9
Well, since you create the windows in FrameWndProc() upon receiving a NEW_DOCUMENT message, it should be fairly easy to get the handles to those windows, shouldn't it?

I dont understand what u mean :S

anyway here is code that adds form names to treeview.

Expand|Select|Wrap|Line Numbers
  1.             for(int i = 1; i < this.MdiChildren.Length;i++)
  2.                 {
  3.                         PrivMsg.Nodes.Clear();
  4.                         PrivMsg.Nodes.Add(this.MdiChildren[i].Name.ToString());
  5.                 }
Still havent figured it out :S plz help
Mar 14 '08 #5
Sick0Fant
121 100+
If you already have the nodes in the treeview, then it should fire an event everytime the user clicks on a different node. You don't need to create this event--it's fired automatically. You just need to handle it.
Mar 14 '08 #6
balabaster
797 Expert 512MB
I dont understand what u mean :S

anyway here is code that adds form names to treeview.

Expand|Select|Wrap|Line Numbers
  1.  for(int i = 1; i < this.MdiChildren.Length;i++)
  2. {
  3. PrivMsg.Nodes.Clear();
  4. PrivMsg.Nodes.Add(this.MdiChildren[i].Name.ToString());
  5. }
Still havent figured it out :S plz help
Before you add the node, I would pass i into the tag of that node, this way you can easily select the relevant MDI form when the node is selected instead of having to iterate through your forms looking for the one with the relevant name.

VB
Expand|Select|Wrap|Line Numbers
  1. Private Sub TreeView1_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) _
  2.   Handles TreeView1.AfterSelect
  3.     Dim oNode As TreeNode = TreeView1.SelectedNode
  4.     If (Not oNode Is Nothing) AndAlso (Not oNode.Tag Is Nothing) Then
  5.     Dim iFormIndex As Integer = 0
  6.     If TypeOf oNode.Tag Is GetType(Integer) Then iFormIndex = CInt(oNode.Tag)
  7.     Dim Children() As Form = Me.MdiChildren
  8.     Children(iFormIndex).Activate()
  9. End If
C#
Expand|Select|Wrap|Line Numbers
  1. TreeNode oNode = null;
  2. if ((oNode != null) && (oNode.Tag != null)){
  3.   Int32 iFormIndex = 0;
  4.   if (typeof(oNode.Tag) == GetType(Int32)){
  5.     form[] Children = this.MdiChildren;
  6.     Children[iFormIndex].Activate();
  7.   }
  8. }
That should be akin to what you're looking for - it may need some tweaking to do exactly what you're after.
Mar 14 '08 #7
fadah
9
Thanks for your replays.I will try those optionses out.
Mar 16 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Brian Smith | last post by:
Is there a way to avoid the default action of TreeNode expansion/contraction caused by double click? I can add an event handler to pop up my properties dialog on double click, but it has the...
3
by: feel | last post by:
Goin' crazy with this recursive function ported from delphi... I send a string like DirA/ DirB /DirC but i get in the treeView each one in a new node.Cant get the child node....!! -DirA -DirB...
5
by: SoKool | last post by:
Can anyone point me to a site where I can get a free treeview control to use in ASP .NET or any tutorial that can help me build my own treeview control. I intend to use a treeview to generate a...
8
by: Hrvoje Voda | last post by:
What is wrong in this code? private void tree_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == Keys.Enter ) {
6
by: L.M | last post by:
Hello, I knew how to use the treeview under VB6. After migrating to .NET, well, I'm lost. I try to add a new node, either to the same level or as a child to a selected node in the treeview....
3
by: Gary Dunne | last post by:
I'm writing an app that requires drag and drop operation between a ListView and a TreeView control. (The source is the ListView). During the drag drop operation I want to be able to detect the...
0
by: Christof Nordiek | last post by:
Hi, Below is a simple program that demonstrates my poblem. i fill a treeview with nine nodes. Then the treeview is shown with a scrollbar. But I can't scroll to the last item. scrolling to the...
3
by: dutsnekcirf | last post by:
I have a treeview control on a custom task pane in Excel. I've enable the ability to use Drag & Drop (by following this how-to) on the treeview to change the order of the nodes. The problem though...
1
by: =?Utf-8?B?QW5kcmV3?= | last post by:
I am trying to adapt some code that I have where I drag and drop from two treeview controls. Now I want to drag and drop from a listview to a treeview. Whatever I do does not work and I cannot find...
0
by: =?Utf-8?B?QW5kcmV3?= | last post by:
I have some code that I use to drag and drop from treeview to treeview, now I want to adapt the code to drag and drop from listview to treeview. I am having problems adapting the code nor can I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.