Hi srini,
After doing ExpandAll(Nothing, EventArgs.Empty)
No error but it doesn't work i mean the event doesn't fire arggg!!!
I have done everything i have included all the code to scan trough below!
Thx
My code below:-
Public Sub ExpandAll(ByVal sender As Object, ByVal e As System.EventArgs)
For i As Integer = 0 To tvFamilyTree.Nodes.Count - 1
tvFamilyTree.Nodes(i).Expanded = True
Next
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
ExpandAll(Nothing, EventArgs.Empty)
End Sub
In ASp.NET
-------------
<asp:Button BorderColor=#009966 Runat=server
OnClick="ExpandAll"></asp:Button>
My TreeView:-
-----------------
<IE:TREEVIEW id="tvFamilyTree" runat="server"
SystemImagesPath="/webctrl_client/1_0/images/"
SHOWLINES="true" SHOWTOOLTIP="true"
DefaultStyle="font-family:arial;font-size:11px;color:#004080;border: solid
0px #004080; margin: 0px; background: #ffffff; white-space:
nowrap;cursor:default;"
HoverStyle="font-family:arial;font-weight:bold;font-size:11px;color:red;text-decoration:underline
red; margin: 0px; background:#ffffff; white-space: nowrap;
cursor
ointer;cursor:hand;"
BorderStyle="0" Showplus="true" Indent="5" ExpandedImageUrl="smallest.gif"
SelectExpands="true">
<ie:TreeNode TreeNodeSrc="MyXmlfile.xml" Text="<font size='4'>Call
Center</font>" Expanded="True" ID="Treenode1"
NavigateUrl="default.aspx"></ie:TreeNode>
</IE:TREEVIEW>
srini said:
Hi Martin,
Thanks for the inputs.
If you see the last line of my message i asked not to call the ExpandAll in
the page load again. But its a really valid point. We can call
ExpandAll(nothing, eventargs.empty).
Thanks again
srini
Martin Dechev said:
Hi,
Why all this overhead - attaching to the Init event, attaching another
method to the Load event? He'd better call it directly from Page_Load:
Private Sub Page_Load(sender As Object, e As EventArgs) _
Handles MyBase.Load
'Put user code to initialize the page here
ExpandAll(Nothing, EventArgs.Empty)
End Sub
Hope this helps
Martin Dechev
ASP.NET MVP
srini said:
Hi Patrick,
I am not sure if this is the best way to do it but you can do it this way.
In the Page_Init method keep the following code
If Not Page.IsPostBack Then ''If you dont want to call the method during
postbacks
AddHandler Me.Load, AddressOf ExpandAll
End If
Now you dont need to call the ExpandAll on the page Load.
HTH
srini
:
Hi Srini,
I added
Public Sub ExpandAll(Byval sender As Object, Byval e As System.EventArgs)
But in my Page_load:-
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
ExpandAll()
End Sub
The Expand() needs some argument!!(Argument not specified for parameter e)
Any ideas
VS.NET marks it as an error
:
Hi Patrick,
The ExpandAll method shoulf have the same signature as a delegate so the
ExpandAll should be like
Public Sub ExpandAll(Byval sender As Object, Byval e As System.EventArgs)
HTH
srini
:
Thx srini changed it but now i still get the error:-
Method 'Public Sub ExpandAll()' does not have the same signature as delegate
'Delegate Sub EventHandler(sender As Object, e As System.EventArgs)'.
Code below:-
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
' ExpandAll()
End Sub
Public Sub ExpandAll()
For i As Integer = 0 To tvFamilyTree.Nodes.Count - 1
tvFamilyTree.Nodes(i).Expanded = True
Next
End Sub
ASP.NET
---------
<asp:Button BorderColor=#009966 Runat=server OnClick="ExpandAll"
ID="Button1"></asp:Button>
Anu idea what i'm doing wrong!!
Patrick
:
Hi Patrcik,
Modify the line of code
<asp:Button BorderColor=#009966 Runat=server
OnClick="ExpandAll()"></asp:Button>
to
<asp:Button BorderColor=#009966 Runat=server
OnClick="ExpandAll"></asp:Button> and check.
You dont need to give a parenthesis here.
HTH
srini
:
Hi All
i'm getting error with my TreeView Menu(I want to have a button with
ExpandALL and CollapseALL):-
Error:-
'AddressOf' operand must be the name of a method; no parentheses are needed.
I use VB.Net and i changed the C# code from:-
private void ExpandAll()
{
for(int i=0; i < yourTree.Nodes.Count; i++)
{
yourTree.Nodes.Expanded = true;
}
}
TO
Public Sub ExpandAll()
Dim i As Integer
For i = 0 To tvFamilyTree.Nodes.Count - 1 Step i + 1
tvFamilyTree.Nodes(i).Expanded = True
Next
End Sub
And called ExapndAll in page load
And on my ASP.NET page called it like this:-
<asp:Button BorderColor=#009966 Runat=server
OnClick="ExpandAll()"></asp:Button>
Can u telling me what 'm doing wrong!!
Thx