|
Hi guys,
I need some help please, I have a treeview with menu items where one of them opens an add form and allows the user to select a name. Once the name is selected and saved into the database, I would like to update/refresh the tree with the new node automatically on save.
Please help!
sasa
|
|
|
|
|
SASA_1 wrote: I would like to update/refresh the tree with the new node automatically on save.
You mean when your app starts it should restore the treeview?
You could additionaly save your username like that: users/admins/tony (depends on your structure of course)
You can then recursively call Node.Expand to restore your tree view.
Here's some sample code from a project I work on:
private void ExpandTree(string path)
{
path = path.Replace(@"\\", @"\");
string[] paths = path.Split('\\');
if (paths.Length > 0)
{
TreeNodeCollection currentNodePath = this.trTreeView.Nodes;
TreeNode currentNode = currentNodePath[0];
for (int i = 0; i < paths.Length; i++)
{
foreach (TreeNode node in currentNodePath)
{
if (node.Text.ToLower() == paths[i].ToLower())
{
node.Expand();
currentNodePath = node.Nodes;
currentNode = node;
break;
}
}
}
}
}
You might need to modify it for you needs, though.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank you for your suggestion but, my app does restore the treeview when I restart the app, I just want it to restore the treeview on every node added after it is started.
sasa
|
|
|
|
|
Hello
I don't seem to fully understand your problem. how do you populate your TreeView? I usually make a RefreshTree() that populates my TreeView, and call it each time a change happens. So refresh your TreeView just in the same manner you populate it the first time!!
Again I think I'm not aware of your true problem. Please post me more details on how you populate you TreeView, and if there is any Databinding involoved, or do you explicitly populate you TreeView from a DataSource without binding.
Regards
|
|
|
|
|
How do you compile to a library in C#. or how can i bring a DLL into the final exe so I don't have to install the dll.
I have classes that i use often and don't like just copying the .cs into my project. I'd like a library to link from but don't know how to make it.
Thanks
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
HahnTech wrote: How do you compile to a library in C#
Create a class library project and just compile it
HahnTech wrote: or how can i bring a DLL into the final exe so I don't have to install the dll.
copy the code over from the DLL to your form.
This is ugly, the better way is:
HahnTech wrote: I'd like a library to link from but don't know how to make it.
Add a reference to your DLL from your form.
In the solution explorer there a folder called "References". You can there rightclick, "Add Reference" -> "Browse" -> select your DLL
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I can make a DLL by using the create a class library project. And i can add a made dll as a reference into a new project but then i have to push the dll with the exe all the time. In C++ i can compile to a *.lib and tell the linker where the lib file is and it will compile the code from the lib into the exe and i don't need to push the lib all over the place. Is that possible in C#?
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
|
Yes I am!
Thank you!
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
I want to hide my Windows Application in System Tray on minimizing. How can I do that? The user may be able to maximize the Application on clicking the icon in System tray. Please give me suggestion of how to do that?
Thanks,
Sandeep S. Sekhon
|
|
|
|
|
Some threads below you find a description how to capture the minimizing of your form. Then you only need to call Form.Hide , set Form.ShowInTaskBar false and call Show of a NotifyIcon component dropped on your form at design time. To show your app again register to the NotifyIcon.Click event and reverse the steps described above.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hello
Is there bidirectional iterator(it is desirable for generics) in C#? (May be third party implementation).
Andriy
|
|
|
|
|
There isn't one that I can recall, however, it is relatively easy to make one using the yield keyword in 2.0
only two letters away from being an asset
|
|
|
|
|
Mark, thank you for advice. I think you've meant smth like this:
public IEnumerator<t> GetEnumerator() {
if (left != null) foreach (T x in left) yield x;
yield value;
if (right != null) foreach (T x in right) yield x;
}
But I need calling "MoveNext" and "MovePrevious" in arbitrary order e.g.: "MoveNext", "MoveNext", "MoveNext", "MovePrevious", "MoveNext", "MoveNext".
If you know how to implement discribed behaviour using "yield" please write small code snippet. I haven't found how to do it after investigating C# Specification describing "yield".
I think possible solution can be wrapping LinkedList.
What do you think about this?
|
|
|
|
|
|
Mark, but this sample likes code snippet I've sent you in previous post. It doesn't fit for my task. Because I need calling several "MoveNext" in the side of "Top" not reaching the last element and then call "MovePrevious"(IEnumerator doesn't contain it at all). How can you do it using sample you've sent?
|
|
|
|
|
Sometimes you need to do more than cut & paste. You have all the tools necessary to create what you are asking for. Right, IEnumerator does not have a MovePrevious method, so create one.
only two letters away from being an asset
|
|
|
|
|
Hello
I don't know why you are making things compicated for yourself?? Random access collections work fine in most scenarios!! If you don't want to wrapp an iterator to implement what you need, well, here is a simple - poor pratice- way to simulate what you need.
1- Make a private random access collection. eg. ArrayList
2- Make a private integer to store the current index
3- Make a public object of the type you want to store in the ArayList.
4- Make to public methods MoveNext() , MoveBack() , to increase/decrease the CurrentIndex and store MyIterator[CurrentIndex] in ther public object you created.
Regards
|
|
|
|
|
Thank you, this is what I am about to implement. I've just hoped that there is already implemented bidirectional up-to-date for changes iterator.
|
|
|
|
|
Hello,
I am trying to implement drag within my shell namespace extension. I noticed that in MFC you are able to set up a message area to attach to the events such as OnBeginDrag.
My question is; How do I attach to those events using c#?
Thank you,
Rick
Rick
Rick
|
|
|
|
|
They hide that information in the Documentation[^]
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
led mike
|
|
|
|
|
Yes,
I get that part about the event, but How do i attach to an event that is sent by the windows shell.
Rick
|
|
|
|
|
Rick, with a little Googling i found this CodeProject Article[^] maybe it will help
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
led mike
|
|
|
|
|
hi,
i would like to make a serial communication with an antenna to send and recieve data from another antenna, the first one is connected on a com port of my pc. i program it in visual studio 2003
but i dont know how to start
does anybody know a site with samples that could help me?
thxx
|
|
|
|
|
serial communications are much easier using the provided System.Ports.Serial class in VS05. IF you're unable to use the (free) express edition of 05, there are several user written libraries available on this site if you use the search function.
|
|
|
|