I would like to convert the code below into an asp.net application where I
can run it via the web. It works ok for vb.net, but my goal is to do it
through the browser. I have in a few areas, in particular the
"application.st artuppath" where it's not part of the System.Web.
HttpApplication State. Another area is "trv.Nodes.Add( text_line.Trim( ))"
where value of type string cannot be converted to
Microsoft.web.u i.webcontrol.tr eenode. Also, the "EnsureVisi ble" not
supported it seems. I didn't include the file organization.tx t, but it could
be any file that has tabs denoting the tree structure.
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim file_name As String = Application.Sta rtupPath
file_name = file_name.Subst ring(0, file_name.Lengt h - 1)
file_name = file_name.Subst ring(0, file_name.LastI ndexOf("\"))
file_name &= "\organization3 .txt"
LoadTreeViewFro mFile(file_name , TreeView1)
End Sub
' Load a TreeView control from a file that uses tabs
' to show indentation.
Private Sub LoadTreeViewFro mFile(ByVal file_name As String, ByVal trv As
TreeView)
' Get the file's contents.
Dim stream_reader As New StreamReader(fi le_name)
Dim file_contents As String = stream_reader.R eadToEnd()
stream_reader.C lose()
' Remove line feeds.
file_contents = file_contents.R eplace(vbLf, "")
' Break the file into lines.
Const charCR As Char = CChar(vbCr)
Const charTab As Char = CChar(vbTab)
Dim lines() As String = file_contents.S plit(charCR)
' Process the lines.
Dim text_line As String
Dim level As Integer
Dim tree_nodes() As TreeNode
Dim num_nodes As Integer = 0
ReDim tree_nodes(num_ nodes)
Dim cHA As Char
cHA = " "c
trv.Nodes.Clear ()
For i As Integer = 0 To lines.GetUpperB ound(0)
text_line = lines(i)
If text_line.Trim( ).Length > 0 Then
' See how many tabs are at the start of the line.
level = text_line.Lengt h - text_line.TrimS tart(charTab).L ength
' Make room for the new node.
If level > num_nodes Then
num_nodes = level
ReDim Preserve tree_nodes(num_ nodes)
End If
' Add the new node.
If level = 0 Then
tree_nodes(leve l) = trv.Nodes.Add(t ext_line.Trim() )
Else
tree_nodes(leve l) = tree_nodes(leve l -
1).Nodes.Add(te xt_line.Trim())
End If
tree_nodes(leve l).EnsureVisibl e()
End If
Next i
If trv.Nodes.Count > 0 Then trv.Nodes(0).En sureVisible()
End Sub
--
Hutty 1 3993
Just following up to see if anyone has any ideas on the solution below.
thanks
"Hutty" wrote: I would like to convert the code below into an asp.net application where I can run it via the web. It works ok for vb.net, but my goal is to do it through the browser. I have in a few areas, in particular the "application.st artuppath" where it's not part of the System.Web. HttpApplication State. Another area is "trv.Nodes.Add( text_line.Trim( ))" where value of type string cannot be converted to Microsoft.web.u i.webcontrol.tr eenode. Also, the "EnsureVisi ble" not supported it seems. I didn't include the file organization.tx t, but it could be any file that has tabs denoting the tree structure.
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load Dim file_name As String = Application.Sta rtupPath file_name = file_name.Subst ring(0, file_name.Lengt h - 1) file_name = file_name.Subst ring(0, file_name.LastI ndexOf("\")) file_name &= "\organization3 .txt" LoadTreeViewFro mFile(file_name , TreeView1) End Sub
' Load a TreeView control from a file that uses tabs ' to show indentation. Private Sub LoadTreeViewFro mFile(ByVal file_name As String, ByVal trv As TreeView) ' Get the file's contents. Dim stream_reader As New StreamReader(fi le_name) Dim file_contents As String = stream_reader.R eadToEnd() stream_reader.C lose()
' Remove line feeds. file_contents = file_contents.R eplace(vbLf, "")
' Break the file into lines. Const charCR As Char = CChar(vbCr) Const charTab As Char = CChar(vbTab)
Dim lines() As String = file_contents.S plit(charCR)
' Process the lines. Dim text_line As String Dim level As Integer Dim tree_nodes() As TreeNode Dim num_nodes As Integer = 0 ReDim tree_nodes(num_ nodes) Dim cHA As Char cHA = " "c trv.Nodes.Clear () For i As Integer = 0 To lines.GetUpperB ound(0) text_line = lines(i) If text_line.Trim( ).Length > 0 Then ' See how many tabs are at the start of the line. level = text_line.Lengt h - text_line.TrimS tart(charTab).L ength
' Make room for the new node. If level > num_nodes Then num_nodes = level ReDim Preserve tree_nodes(num_ nodes) End If
' Add the new node. If level = 0 Then tree_nodes(leve l) = trv.Nodes.Add(t ext_line.Trim() ) Else tree_nodes(leve l) = tree_nodes(leve l - 1).Nodes.Add(te xt_line.Trim()) End If tree_nodes(leve l).EnsureVisibl e() End If Next i
If trv.Nodes.Count > 0 Then trv.Nodes(0).En sureVisible() End Sub
-- Hutty This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jim M |
last post by:
Is there any way to know what node was clicked in a treeview webcontrol
where autopostback is false?
Thanks in advance.
|
by: clintonG |
last post by:
I'm just wondering how rich the TreeView control actually is having never
worked with a tree view control.
I want to load XML into the tree and I'd like control of the presentation
tier by getting rid of the folder icons. In fact if possible, I'd like to
display the name of each node as a literal representation of the node
itself, i.e....
|
by: John |
last post by:
Hi all,
I've posted this before but received no answers and it is an issue . . .
One of my pages is using a treeview webcontrol. I load the treeview with
data which only has two levels (i.e. parents and their children).
My question is how can I code the treeview so only once a user has clicked
on one of the children, a postback is...
|
by: Edward |
last post by:
hello, everyone,
I build one tree menu using TreeView webcontrol , everything is ok, from
tree node click, one sub-frame(main) can refresh its content with new url.
My question is, I have another sub-frame(message), message frame and main
frame cannot be shown at the same time, so I wonder, when the message frame
is visible, how can I...
|
by: Charts |
last post by:
I download IEWebControls.exe, and installed it. Installation created IE Web
Controls directory. The readme.txt said,
3. Create a /bin subdirectory for the application and copy the file
Microsoft.Web.UI.WebControls.dll to this directory.
However I could locate Microsoft.Web.UI.WebControls.dll. Actually I could
not find any DLL under the...
| |
by: shen.chang.cs |
last post by:
Hi, all,
I use .Net V2.0 and WebControl TreeView. I want to have an OnClick()
function to handle user click on certain end nodes but not on other
nodes. Someone suggested to use a Java Scripts:
<SCRIPT lang="jscript">
function MyTreeView_onclick( )
{
Action1("onclick" );
|
by: Henrik Stidsen |
last post by:
I need to get the HTML output from a webcontrol as a string instead of
it being rendered on the page.
I have the following code:
Dim SiteMapSource As New SiteMapDataSource()
Dim TreeView1 As New TreeView()
TreeView1.DataSource = SiteMapSource
TreeView1.ShowExpandCollapse = True
|
by: Bill |
last post by:
Is it possible to have different contect menus for each node in a TreeView
control.
I see lots of examples on how to do this using Windows Forms, but the the
webcontrol does not seem to support the mouse_up and mouse_down events.
I can set a context menu for the entire Tree no problem, I just define a
value for the "onContextMenu"...
|
by: mike2006 |
last post by:
Can anybody give the examples of code in C# for insert, remove, navigate, search of data, set of backcolor in WebControl TreeView in Visual Web Developer 2005?
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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. ...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |