473,549 Members | 5,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TreeView question

Hi.
I'm working with the TreeView control in my ASP.NET 1.1 application. I have
a problem I haven't been able to figure out. When I click on a node (not
expand), whether it's a parent node, a child node or a leaf node then a
DataGrid is populated based on the node's ID property. If I expand a node
then the DataGrid is not populated. This works fine. The problem is that
this doesn't work if I collapse the tree. If I collapse the tree then the
collapsed node is being selected (if the currently selected node is a
subnode of the node being collapsed) and the SelectedNodeCha nged event is
fired. This causes the DataGrid to populate again. I've been thinking of a
way to avoid this, but I'm all out of ideas.

I thought of setting a flag when the collapse event was fired and then check
for that flag when the SelectedNodeCha nged event fired to avoid populating
the DataGrid again. Problem is that the SelectedNodeCha nged event fires
before the collapse event.

So, if there are any bright minds out there who can tell me what to do I
would be very grateful.

Thanks,
Shawn
Apr 9 '06 #1
3 2242
Shawn maybe u can post some snippet code.
Patrick

"Shawn" <bo********@hot mail.com> wrote in message
news:%2******** **********@TK2M SFTNGP04.phx.gb l...
Hi.
I'm working with the TreeView control in my ASP.NET 1.1 application. I
have
a problem I haven't been able to figure out. When I click on a node (not
expand), whether it's a parent node, a child node or a leaf node then a
DataGrid is populated based on the node's ID property. If I expand a node
then the DataGrid is not populated. This works fine. The problem is that
this doesn't work if I collapse the tree. If I collapse the tree then the
collapsed node is being selected (if the currently selected node is a
subnode of the node being collapsed) and the SelectedNodeCha nged event is
fired. This causes the DataGrid to populate again. I've been thinking of
a
way to avoid this, but I'm all out of ideas.

I thought of setting a flag when the collapse event was fired and then
check
for that flag when the SelectedNodeCha nged event fired to avoid populating
the DataGrid again. Problem is that the SelectedNodeCha nged event fires
before the collapse event.

So, if there are any bright minds out there who can tell me what to do I
would be very grateful.

Thanks,
Shawn

Apr 10 '06 #2
Hi.
The code isn't available right now, it's at work and I'm not going back
until next week.
The code isn't the problem though. I'll try and explain a little more.

In page_load the whole tree is generated. If I expand a node then nothing
is being done. If I click on a node then a DataGrid is filled based on the
node beeing clicked. This is done by calling my BindData() method from the
method that handles the SelectedNodeCha nged event. That's it really, and it
workes like a charm.

Now, to the problem. If a node is selected and I click to collapse it's
parent node then the parent node becomes selected and the
SelectedNodeCha nged event fires. This causes my DataGrid to fill up with new
data based on the parent node that is now selected. I don't want that to
happen since I haven't clicked on a node, I've just collapsed it.

I'm unable to tell whether a node has been selected or just collapsed. If
there is a way to know this then I could prevent the DataGrid from being
filled up with new data.

Shawn

"Patrick.O. Ige" <na********@hot mail.com> wrote in message
news:e8******** ******@TK2MSFTN GP02.phx.gbl...
Shawn maybe u can post some snippet code.
Patrick

"Shawn" <bo********@hot mail.com> wrote in message
news:%2******** **********@TK2M SFTNGP04.phx.gb l...
Hi.
I'm working with the TreeView control in my ASP.NET 1.1 application. I
have
a problem I haven't been able to figure out. When I click on a node (not
expand), whether it's a parent node, a child node or a leaf node then a
DataGrid is populated based on the node's ID property. If I expand a node
then the DataGrid is not populated. This works fine. The problem is that
this doesn't work if I collapse the tree. If I collapse the tree then the
collapsed node is being selected (if the currently selected node is a
subnode of the node being collapsed) and the SelectedNodeCha nged event is
fired. This causes the DataGrid to populate again. I've been thinking of
a
way to avoid this, but I'm all out of ideas.

I thought of setting a flag when the collapse event was fired and then
check
for that flag when the SelectedNodeCha nged event fired to avoid populating
the DataGrid again. Problem is that the SelectedNodeCha nged event fires
before the collapse event.

So, if there are any bright minds out there who can tell me what to do I
would be very grateful.

Thanks,
Shawn


Apr 10 '06 #3
I came up with a solution. Though I might post it if anyone else has the
same problem.

Dim node As TreeNode
Dim arrayIndex As Array

'Check if the newly selected node is a parent of the previously selected
node.
If e.OldNode.Start sWith(e.NewNode ) Then
arrayIndex = e.NewNode.Split ("."c)

'Get the newly selected node.
If arrayIndex.Leng th = 1 Then
node = TreeView.Nodes( arrayIndex(0))
ElseIf arrayIndex.Leng th = 2 Then
node = TreeView.Nodes( arrayIndex(0)). Nodes(arrayInde x(1))
ElseIf arrayIndex.Leng th = 3 Then
node =
TreeView.Nodes( arrayIndex(0)). Nodes(arrayInde x(1)).Nodes(arr ayIndex(2))
End If

'Only bind data to the DataGrid if this isn't a cause of collapsing the
TreeView.
If node.Expanded = True Then
BindData(e.NewN ode)
End If
Else
BindData(e.NewN ode)
End If
"Shawn" <bo********@hot mail.com> wrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
Hi.
The code isn't available right now, it's at work and I'm not going back
until next week.
The code isn't the problem though. I'll try and explain a little more.

In page_load the whole tree is generated. If I expand a node then nothing
is being done. If I click on a node then a DataGrid is filled based on the
node beeing clicked. This is done by calling my BindData() method from the
method that handles the SelectedNodeCha nged event. That's it really, and it
workes like a charm.

Now, to the problem. If a node is selected and I click to collapse it's
parent node then the parent node becomes selected and the
SelectedNodeCha nged event fires. This causes my DataGrid to fill up with new
data based on the parent node that is now selected. I don't want that to
happen since I haven't clicked on a node, I've just collapsed it.

I'm unable to tell whether a node has been selected or just collapsed. If
there is a way to know this then I could prevent the DataGrid from being
filled up with new data.

Shawn

"Patrick.O. Ige" <na********@hot mail.com> wrote in message
news:e8******** ******@TK2MSFTN GP02.phx.gbl...
Shawn maybe u can post some snippet code.
Patrick

"Shawn" <bo********@hot mail.com> wrote in message
news:%2******** **********@TK2M SFTNGP04.phx.gb l...
Hi.
I'm working with the TreeView control in my ASP.NET 1.1 application. I
have
a problem I haven't been able to figure out. When I click on a node (not
expand), whether it's a parent node, a child node or a leaf node then a
DataGrid is populated based on the node's ID property. If I expand a node
then the DataGrid is not populated. This works fine. The problem is that
this doesn't work if I collapse the tree. If I collapse the tree then the
collapsed node is being selected (if the currently selected node is a
subnode of the node being collapsed) and the SelectedNodeCha nged event is
fired. This causes the DataGrid to populate again. I've been thinking of
a
way to avoid this, but I'm all out of ideas.

I thought of setting a flag when the collapse event was fired and then
check
for that flag when the SelectedNodeCha nged event fired to avoid populating
the DataGrid again. Problem is that the SelectedNodeCha nged event fires
before the collapse event.

So, if there are any bright minds out there who can tell me what to do I
would be very grateful.

Thanks,
Shawn



Apr 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2419
by: Sonia Igla | last post by:
Hi. I need to perform DBLCLK on TreeView Node. I try the following: private static extern int SendMessage(IntPtr hWnd, uint msg, UInt32 wParam, UInt32 lParam); private const UInt32 WM_LBUTTONDBLCLK = 0x203; pTreeNode.TreeView.SelectedNode = pTreeNode;
3
2151
by: Peter | last post by:
Hello Thanks for reviewing my question. I would like to know how can I programmatically select a node Thanks in Advanc Peter
3
441
by: Michael C | last post by:
Hi all, Quick question about the TreeView control. I'm using code like this to determine the currently clicked TreeNode in the TreeView. private void MyTreeView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { currentNode = MyTreeView.GetNodeAt(e.X, e.Y); }
3
1800
by: Tom | last post by:
Sorry... new to this. I trying to figure out how to do a page redirect when someone clicks a treeview node. Does someone have a code snippet for this?
3
11212
by: Gerhard | last post by:
I have the following code in an .net 2.0 project: <asp:Panel Runat="server" id="pnlNavigation" CssClass="pnlNavigation" Width="165px"> <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" CssClass="nav" BorderStyle="None" CollapseImageToolTip="" ExpandImageToolTip="" ShowExpandCollapse="False"> <LevelStyles>...
1
2127
by: Sam | last post by:
Hi, On my main form in my MDI application, I have two treeview, one on the right, which is actually a UserControl inherited from Treeview, and the other on the left. When I click on a node in the left Treeview, all the nodes in BOTH Treeview disappear for some milliseconds. First question: Why do I get this nasty effect? Second...
1
2420
by: Daves | last post by:
Sorry folks but I will be reposting this question from 6/5 until someone gives me an answer - the question is very easy and so ought the answer to be. I really need the answer! ------- I'm sorry for reposting but I've already googled for hours and I see others have asked about this here without getting replies, this is starting to look...
8
12741
by: Matt MacDonald | last post by:
Hi All, I have a form that displays hierarchical categories in a treeview. Ok so far so good. What I was to do is have users be able to select a node in the treeview as part of filling out the form. I only want to allow single selection, so using checkboxes is out of the question. It works as is, but it makes the form very cumbersome if...
7
7824
by: Joe Cool | last post by:
Let's say I have a Treeview control on a form. Each leaf node in the Treeview has a ContextMenuStrip, each with one ToolStripMenuItem, and all ToolStripMenuItems Click event is handled by a comment event handler. How do I determine which Treeview Node signalled the menu event in the common event handler?
9
6120
by: auntiejack56 | last post by:
Hi, I've got a treeview, and I want to display the node text property that I have a) clicked on or b) highlighted using the up or down arrows
0
7526
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7723
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7962
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7480
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7814
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5373
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5092
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.