|
sorry Ankur
this was to easy i tried this and variants until 4AM nothing works this way.
i don't get the Items from the controls this way;
thanks for the message anyway i have used the link you give, it go's faster this way for 70%
|
|
|
|
|
Ankur is correct, but it could be done a little better, rather than just translating your VB code:
foreach (Control c in Panel1.Controls)
{
PictureBox picdata = c as PictureBox;
if (picdata != null)
{
...
}
}
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Thanks OriginalGriff
this works
thanks again for the message
|
|
|
|
|
Yep, I agree. My "Good Answer" vote goes to you.
..Go Green..
|
|
|
|
|
Aw! Thank you...
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
I have a treeview where multiple nodes are tagged with the same tag object. When one node's text is changed, i'm using the tag object to trigger an event to change the text for all the rest of the nodes tied to this tag object. After having close to 1000 nodes tied to the same tag object, the text update takes forever. I put some print statements inside the delegate method to see how the invocation list is being executed. Well it seems that the more delegate methods registered the slower it goes from each delegate method to the next. Why would an increase in length of the invocation list slow down transition from one delegate method to the next?
|
|
|
|
|
I think that's because when you change the other nodes' text you trigger your event again, so that execution time goes up exponentially.
You need to inhibit event triggering before you start updating all the nodes, and re-enable it when you're done.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
Moreno is likely correct. Don't trigger on the text changed, trigger on data changed.
|
|
|
|
|
I'm using AfterLabelEdit to trigger the main text change event. I also put print statements inside the custom UpdateText method of my custom TreeNode, the same UpdateText that is added as a delegate to the invocation list of the eventhandler inside the tag object. The print statements increment a counter each time text is updated. With 40 nodes to update, I get '1, 2, 3,...' and so on fairly quickly. With 1000, it take a while for each counter to print, which indicates longer time between invocation method execution. Any thoughts? thanx.
|
|
|
|
|
Can you post a code snippet ?
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
********************************************************
public class MyTreeNode: TreeNode
{...
public MyTreeNode(TagObject obj)
{
...
this.Tag = obj;
obj.TextChanged += new EventHandler(UpdateText);
...
}
public void UpdateTagText(string text)
{
((TagObject)this.Tag).Name = text;
}
public void UpdateText(object sender, EventArgs e)
{
this.Text = ((TextChangedEventArgs)e).Text; System.Diagnostics.Debug.WriteLine(((TagObject)this.Tag).c++.ToString());
}...
***********************************************************************
public class TagObject
{
public event EventHandler TextChanged;
private string name;
public int c = 0;
...
public string Name
{
get { return this.name; }
set
{
this.SetName(value);
}
}
// Invoke the TextChanged event when text changes
public void OnTextChanged(TextChangedEventArgs e)
{
if (TextChanged != null)
TextChanged(this, e);
}
private void SetName(string text)
{
this.name = text;
TextChangedEventArgs ea = new TextChangedEventArgs();
ea.Text = text;
OnTextChanged(ea);
}...
}
public class TextChangedEventArgs : EventArgs
{
private string text;
public string Text
{
get { return this.text; }
set { this.text = value; }
}
}
*****************************************************************
from the form class that contains my treeview:
...
private void treeView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
{
((MyTreeNode)e.Node).UpdateTagText(e.label);
}
...
|
|
|
|
|
I made a few tests, and it seems the problem is not with delegate invocation.
If you disable all events and try this:
DateTime Start = DateTime.Now;
string MyLabel = "Test";
for (int i = 0; i < treeView.Nodes.Count; i++)
{
treeView.Nodes[i].Text = MyLabel;
}
TimeSpan ts = DateTime.Now.Subtract(Start);
MessageBox.Show(ts.TotalSeconds.ToString("0.000"));
You'll see it takes just the same time. So, the problem is the time the TreeNode component takes to update its text.
I tried disabiling on-screen updating, with Visible , Enabled , SuspendLayout() / ResumeLayout() and the WM_SETREDRAW window message, but it doesn't seem to gain you time.
So, I'm afraid you cannot make it faster unless you design your own TreeView / TreeNode classes optimizing them for text updating. If that's possible.
Good luck, let me know if you find any solution.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
I wouldn't use any node (or tree) events to trigger the updates.
I'm not sure how you implemented it, but what I envisioned when pondering your post the other week, wouldn't require it.
|
|
|
|
|
But why does the time it takes for node to update its text depend on the number of nodes in a tree? Because if I update node text when only 50 nodes are tagged with the same object is very fast compared to when 1000 are tagged with the same obj.
|
|
|
|
|
ok, solved it. The idea is to have treeview beginupdate in the begginning of the textchanged delegate invocation and endupdate at the end when all nodes are updated.
public class TagObject
{...
public event EventHandler TextChanged;
public int TextChangedCount;
public bool startOfInvocation;
...
public void OnTextChanged(TextChangedEventArgs e)
{
if (TextChanged != null)
{
this.TextChangedCount = TextChanged.GetInvocationList().GetLength(0);
this.startOfInvocation = true;
TextChanged(this, e);
}
}
*******************************************************************8
public class MyTreeNode : TreeNode
{...
public void UpdateTagText(string text)
{
((TagObject)this.Tag).Name = text;
}...
public void UpdateText(object sender, EventArgs e)
{
TagObject tagObj = (TagObject)this.Tag;
if (tagObj.startOfInvocation)
{
this.TreeView.BeginUpdate();
tagObj.startOfInvocation = false;
}
this.Text = ((TextChangedEventArgs)e).Text;
tagObj.TextChangedCount--;
if (tagObj.TextChangedCount == 0)
{
this.TreeView.EndUpdate();
}
}
takes about a sec for 500 nodes.
|
|
|
|
|
I have a Windows Service written in C#.
This service uses PInvoke to interface with a DLL written entirely in MFC.
When I debug the service, VS 2010 refuses to step into the dll, and doesn't even show it loaded in the Modules window. I know it's loaded because the service is performing its intended function.
I have checked the box that says, "Enable native code debugging," and I can't figure out why VS 2010 isn't letting me debug the DLL.
Is there some trick to it?
|
|
|
|
|
|
I typically don't use Visual at all to debug mixed managed/native situations. I tend to rely on logging most of the time, so I always implement logging on the managed side, then add it on the native side too, and make sure they get merged early on.
If interested, have a look at "two-side logging" in this article[^].
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Thanks Luc. It used to work in 2008, though. I wonder what they broke.
|
|
|
|
|
Can't help you there, haven't done any native code development on VS2010 yet.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hi everyone , i need a way to embed excel sheet in my windows form in C#
i need a way to embed it in my application either depending on preinstalled office package or without , i don't care , i just need to show the excel sheet hosted within my windows form application .
is there a way ????
Human knowledge belongs to the world.
|
|
|
|
|
|
First thank you for your honest reply .
i have looked at the web page you have sent to me , but they said that the web components are discontinued for office 2007 .
any way , i have found a good solution , really amazing solution , it is called DSO Framer ActiveX control from microsoft , it is built using c++ , it is a collection of c++ wrappers that can open any type of office files embedded into your windows application , it is awesome my friend you should look at it .
you can go to cnet.com and search for dsoframer , when you download it you will find good samples written in c++ and vb.net that uses that amazing control to host office files , it is really awesome .
do you know any way to embed pdf files as well ???
Thank you my friend for your reply
Human knowledge belongs to the world.
|
|
|
|
|
snouto wrote: do you know any way to embed pdf files as well ???
You could abuse the WebBrowser control to display the PDF. Should work as long as there's a reader installed
I are Troll
|
|
|
|
|
so I have a DateTimePicker that currently is set to show time only.
right now when the user clicks on the drop down button it shows the calendar.
I need a method to only show time or disable the dropdown event from happening so not to show calendar
this control I need it for Time Selection only//
Any Ideas?
Thanks in advance
|
|
|
|