|
If have this code:
I want to cross the treeview for when I select one one, collapse the rest (if are expanded), except the branch of the node that are selected
Dim nodo As TreeNode
For Each nodo In CatalogTree.Nodes
If SelNode.IsSelected Then
If Not SelNode Is nodo Then
nodo.Collapse()
End If
End If
Next
When I execute the application, all the tree are collapsed, but I don't want collapse the branch of the node that are selected.
Sorry for my English, I'm for spain.
Thanks
|
|
|
|
|
You've got the right idea, you just need a little more thinking about the problem. You need to do two things.
First, you have to create a list of nodes starting from the currently selected node and working your way back up the tree till you find the root. For each step up the tree, you'll add this node to your list. Use the current node's Parent property.
Second, the code you posted is almost correct. You can then iterate through all the node, and child nodes if your requirements dictate it, and compare it to the nodes in your list. If the node is in the list, DON'T collapse it. If it isn't in the list, well, you know what to do...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for you reply, but I don't understand very well.
Can you post me the code, please? I have been proving the following thing that I see in this project: http://www.codeproject.com/cs/miscctrl/favoritescontrol.asp[^]
This project are in csharp and I convert some parts to vb.net
Now, I have this
First, one declaration of two points
Private _intX As Integer = 0
Private _intY As Integer = 0
Second, in the click event:
Private Sub CatalogTree_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CatalogTree.Click
Dim objTreeView As TreeView = CType(sender, TreeView)
Dim objNode As TreeNode = objTreeView.GetNodeAt(_intX, _intY)
Dim CurrentNode
Dim CurrentNodeName
Dim CurrentNodeRaiz
If Not objNode Is Nothing Then
If Not objNode.Tag Is Nothing Then
'A URL was clicked
CurrentNode = objNode.Tag
CurrentNodeName = objNode.Text
'RaiseEvent URLClick(Me, New System.EventArgs)
Else
'A folder node was clicked
CurrentNodeRaiz = objNode.Text
'Collapse all sibling nodes so only one folder is open at any given level
_CollapseSiblings(objNode)
'Toggle the folder
If Not objNode.IsExpanded Then
objNode.Expand()
Else
objNode.Collapse()
End If
End If
End If
End Sub
Third, in the mousedown event
Private Sub CatalogTree_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CatalogTree.MouseDown
_intX = e.X
_intY = e.Y
End Sub
and finally, one method for collapse nodes
'By Sergio
Private Function _CollapseSiblings(ByVal aobjNode As TreeNode)
Dim objNode As TreeNode = aobjNode.PrevNode
While Not objNode Is Nothing
objNode.Collapse()
objNode = objNode.PrevNode
End While
objNode = aobjNode.NextNode
While Not objNode Is Nothing
objNode.Collapse()
objNode = objNode.NextNode
End While
End Function
The link of the project that I have seen works good.
But the code that I post don't collapse any node.
What I can do?
|
|
|
|
|
I don't have nay example code, nor do I have the time to write it.
Quit cutting and pasting someone elses code and trying to make it work how you want. If you want it to work, write your own. You'll at least have a much better understanding of how your code works over someone elses.
For a better understanding of how to navigate up a node tree and save the path to the root of the tree, see Creating A Breadcrumb Control[^] on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks for your time.
Finally, I have obtained that I want modifying the treeview click event.
|
|
|
|
|
Hi,
Thx a lot for the previous answer.
For loading a pack of records into comboBox ,which event is best ?
form_load or InitializeComponent.
Could you pls explain it?
regards,
aB
|
|
|
|
|
Definitely on the Load()
InitializeComponent() is called from the constructor, and as the name says, it does construct the form, that means the form is not completely created.
Load() is called after New() .
I use to compare it to the OnInitDialog() handler in C++ Dialog based applications.
so, create whatever you want in the New() , and initialize them on the Load()
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
hi
how i can print a form via vb in a page with size A5
noted, i use this code for print in A4
frmPrintFish.ScaleMode = vbTwips
sWide = 8.5
sTall = 11 ' or 14, etc.
frmPrintFish.Width = twipFactor * sWide
frmPrintFish.Height = twipFactor * sTall
and the varible twipfactor is set to 1440
please give me solution
|
|
|
|
|
I want to know who are opening/update/rename/delete my file thru LAN when my folder are open network sharing.
I need to know how to write this code for me to trace out who making modify of my file.
|
|
|
|
|
As far as I can tell, you can't do this in Windows. I haven't been able to find a "WhoHas" utility nor can I find any Win32 API's that will even hint at this functionality.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I know that. My method is use "FileSystemWatcher" to know which file was modify. And hope at the same time can know who modify it thru LAN.
|
|
|
|
|
There's no way to do it with the FileSystemWatcher either. All you'll know is one of the people attached to that server modified the file, but not which one of them.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for your help.
So, have any others method to do that job? May link with IPhost, or any others? Because I not familier with the IP networking development. Or may be can use host together with the timer? Means when the file was modify, then scan the LAN IP address and know which IP are in the folder?
|
|
|
|
|
There is no association between Files/Folders and IP's or user ID's. THere is no way to connect the two to get the information you want.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks a lot.
|
|
|
|
|
Hi All!
I wrote a abstract class in VB.net and just define 4 methods than I inherit this class to derived class B and also with CLass C. In Class B I Implemented all 4 methods but in Class C I want to use just 2 methods. I know this is possible that just give complete defination of 2 methods that i want to use and leave empty rest of them.
When I make an object of Class C and try to access it s methods then it shows all 4 methods, I wana hide it s 2 method, which are not complety define in Class C.
any idea???
Thanks
|
|
|
|
|
It sounds like two of the four methods need to either be not abstract, or more likely defined in an interface that only class B uses. You definately cannot hide methods from a base class on a class by class basis, that would be ridiculous.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
i use flat file system in my vb.net project.
when i load data ,say CustName to a comboBox i want to have the corresponding CustID somewhere (like selecteindices.item in Listview control) so that i can catch that Id when user select a particular CustName.
1.Is there any property available in ComboBox to store a pair values.
2. How to override a .net windows control's property that is overridable.
3. Is it possible to override comboBox.items.item property ? how ?
Regards,
aB
|
|
|
|
|
baste wrote:
Is there any property available in ComboBox to store a pair values.
Yes, a combobox can store any value you like. Just set the DisplayMember property to be a property on the class you're adding, so that it knows where to look for the string to display.
baste wrote:
How to override a .net windows control's property that is overridable.
Derive a class from the control class, in this case, ComboBox. However, you don't need to in this case.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I want to display a table on my form. I understanbd that there is a table control. My documentation shows me how to populate the table. But I can't find the table control in my toolbox. How do I get the table control into my toolbox.
Thanks
|
|
|
|
|
Would you be looking for the DataGrid? AFAIK, it's the only "Table Control" in the toolbox.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm trying to get all images tags from an html file...
i'm clearly doing something wrong but cant find what...
I only get 5-6 link on a page containing at least 30-40 img tag.
Some to take a look ?
<br />
dim data as string ' contains the html data<br />
Dim resultcol As New Collections.Specialized.StringCollection<br />
For Each mt As Match In Regex.Matches(data, "\<img src=['""](?<url>[^'""]+?)['""]", RegexOptions.IgnoreCase Or RegexOptions.Singleline)<br />
Dim deb As String = mt.Groups("url").Value<br />
If Not resultcol.Contains(deb) Then<br />
resultcol.Add(deb)<br />
End If<br />
Next<br />
|
|
|
|
|
You forgot that there may be other attributes between the "img" tag and the "src" attribute (e.g., "alt". Try to change your regex from "img src" to, e.g., "img.*?src" and your problem will be solved.
I see dead pixels
Yes, even I am blogging now!
|
|
|
|
|
Hia Daniel,
And thanks for your answer.
You're right about this point.
But I still cant get all the tags.
For sample:
I catch
<br />
<img src="themes/smartDark/images/7px.gif" width="7" height="7"><br />
but not
<br />
<img src="http://www.thehorde.be/l2/yy2.gif" /><br />
The only difference I see is the extra pair in the catched match.
But weird,I dont catch
<br />
<img src="images/blocks/group-4.gif" height="14" width="17"><br />
while I catch this one , later in the file
<br />
<img src="images/logononame.gif" border="0" alt="hosted by Noname Team" title="www.noname.fr" ><br />
They look the same
|
|
|
|
|
Ricalawaba wrote:
They look the same
Try to change your expression from "img src" to "img\s*src": webpages often have multiple space chars, or even have tabs or other chars (like #161) that look like a space, but is not a space. \s will match all of them.
I see dead pixels
Yes, even I am blogging now!
|
|
|
|