|
Glad you are making progress on your solution !
Obviously, you've come up on the issue of performance, and here a few comments I hope you will find useful:
By the way: have you explored all the possible uses in your scenario of TreeNode.Clone() ... which .... from MSDN: "Copies the tree node and the entire subtree rooted at this tree node." ... ?
0. is there any way you can limit the update to some user-initiated update (i.e., make it a batch operation), which of course may mean you'd have to tolerate a mis-match visually between the two TreeViews, assuming both are displayed at the same time.
If you can "get away with that," then I'd disable the second TreeView anytime it was not synchronized, after some change had been made in the primary TreeView, but the user had not initiated an update.
1. however, if it is an absolute requirement that checking any TreeNode results in immediate changes in the second TreeView: then there are several ideas to explore:
a. since you can get an Event for any TreeNode CheckState changed: and having access to the changed Node also gives you access to its Parent property: does that give you enough information to do a partial update ?
b. whether the FullPath property of a TreeNode could be useful here ? I doubt it, since the WinForms TV gives you no useful methods to use that FullPath to directly get at TreeNodes (by, for example, using only part of the FullPath returned string).
2. view virtualization (showing only what you need to show as updated): I think there may be an example on here on CP of a TreeView supporting "virtual screen update" which means changes are made as they are required to be displayed: while I doubt that's relevant here, at least you might check it out ... for ideas.
3. flatlist: the third-party commercial TreeView I use (Lidor Systems IntegralUI TreeView) maintains a flattened list of all Nodes in depth-first order, which makes operations like the kind of updates you are looking at very much easier: and many other features including "virtualization of view." The WinForms TreeView, by comparison, is a "toy." Yes, that's a recommendation ... and no I don't work for Lidor.
a. on StackOverFlow you'll some good examples of how to create a flattened TreeView List of Nodes, based on ideas of Eric Lippert influenced by ideas of Wes Dyer: the method uses a stack to avoid the high performance/memory costs of true recursion. Check out this thread I started on SO a long time ago: [^].
4. finally, if immediate synchronization of both views here is the goal: re-consider Luc Patyn's suggestion to use your own tree data structure, and map it as needed to "views."
good luck, Bill
"It is the mark of an educated mind to be able to entertain a thought without accepting it." Aristotle
|
|
|
|
|
i called it in after check event of treeview1 it worked with out need for button.
thanks alot BILL
JANARDHAN
|
|
|
|
|
Hi all,
I program a Snake game using C#.
I have a problem when I moving the snake.
I have a while loop to made the snake move while it's not dead.
Here is the code:
while (!mainSnake.isDead)
{
mainSnake.makeMove();
PicCanvas.Invalidate();
Thread.Sleep(500);
}
The problem is that I don't see the moves of the snake. I just see the "Game Over" mesagebox when the snake "hit the wall".
I want to see any move of the snake (with 500 millisecond delay between any move).
Any ideas?
Thanks ahead.
|
|
|
|
|
I guess the code shown sits in some event handler, i.e. it is executing on the main thread and blocking everything else, until it terminates due to the snake dying. This is what you should do:
- get rid of Thread.Sleep(), it should not be used inside event handlers.
- use a timer instead; for actions that mainly influence the GUI, a System.Windows.Forms.Timer is the right choice.
- put one iteration of your loop inside the timer's tick handler.
|
|
|
|
|
Thank you the timer really worked!
|
|
|
|
|
hi
in my C# program i have export to csv file.
how to preserve zero bebore number in csv file that opens on excell
for example:
i see in my program: 00012345
and if i open on excell i see 12345
thanks in advance
|
|
|
|
|
Add an apostrophe (') before the number and excel will treat it as a text column and display the leading zeroes.
|
|
|
|
|
This is an Excel formatting issue. You should set the cell format for the field in question to display a fixed number of digits for any numeric values.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
AFAIK, csv files do not support formatting.
|
|
|
|
|
I did not say that they did.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I want convert word doc or word file to image such as tif
|
|
|
|
|
Why would you want to do that? There may be better approaches.
|
|
|
|
|
hey guys i need help plz
i want when i press enter in cell cursor go down to the the cell in same column but when i press tab go to next cell in the same row how ?
|
|
|
|
|
I have just tried this and added a new datagridview to a windows form, and what you want is the default behaviour.
What appears to be the problem that it is not doing this?
|
|
|
|
|
Hi ,
I have a webservice FindStates()which return XML of all the states.
My webservice returns data in a dataset.
1) How to fetch the data from this webservice and put the same data in my database table.
Note: I have the same table structure.
Thanks,
Sandy
|
|
|
|
|
Hi what have you tried (in client)? Is the web service returning Json or xml?
[edit] changed icon [edit/]
Frazzle the name say's it all
|
|
|
|
|
|
Actually the code looks like below
DataSet ds = Webserviceobj.GetStates();
/// from here i want to insert the data which is returned by GetStates in to my table.
For example Getstatus webmethod return
Id state
1 karnataka
2 tamilnadu
3 andhrapradesh
So this data is there in the dataset ds. Now i want code to pass this dataset data in to my database table.
Can any one help me in this regrad.
Thanks,
Sandy
|
|
|
|
|
Create a data adapter to the destination table and update the adapter as -
DataAdapter.Update( dataSet ).
|
|
|
|
|
If the XML is produced from DataSet.WriteXml, you can reconstruct it at the other end using DataSet.ReadXml. It's probably a good idea to emit the schema so that if the web service is updated to have extra columns or tables, it doesn't just crash existing clients.
|
|
|
|
|
I have a project wiht 3 tabs.
When I push the 2nd tab, I want to up pop a messagebox.
How can I do this?
Kiter
|
|
|
|
|
|
Maybe a TabControl has a bunch of Events, and fires one or more of them when you switch to another tab? That is what I have come to expect from WinForm Controls.
Did you bother reading some of the documentation?
|
|
|
|
|
hi
For Example My Tabcontrol name is TBC1
so
1. select TBC1 and go to Events on Propertes windows
2. Click the SelectedTabPageChanged events
3. and this step write the flowing code
....
if(TBC1.SelectedTabPageIndex==1)
MessageBox.Show("You select 2nd Tab of Tab Control");
//The First Tab index=0
|
|
|
|
|