|
I'm not sure that I am correct, but I think you are actually resetting the what is shown on the screen with your line of:
NewNode.Text = "Node: " + i.ToString();
Thus it is having to rewrite over the same information. If you don't make the call to Application.DoEvents(); I think you will see that your screen does not flutter. Is there a reason that you are trying to process all the messages in the message queue here? Something like this should work fine.
TreeNode NewNode;
for( int i = 0; i < 1000; i++ )
{
NewNode = treeView.Nodes.Add( "Node: " + i.ToString() );
NewNode.Text = "Node: " + i.ToString();
}
HTH
Nick Parker
|
|
|
|
|
In MFC/Win32 when I change the text of a node it doesn't trigger the entire redraw of the the tree control I was just expecting the control to act the same way.
I'm mean I should be able to change the text of a node in a loop for more than one reason, progress, size increasing, etc.
If you look at the following link you'll see an application that uses that methode with processing messages or a thread but it his still updating the treeview wile giving control of the application to the user.
www.jamsoft.net/treesize.html
This example is in MFC (sorry to post this is a c# forum) and it changes the text of a node after it was added and it does not cause the entire control to redaw.
HTREEITEM NewNode;
CString strText;
for( int i = 0; i < 1000; i++ )
{
strText.Format( "Node: %d", i );
NewNode = m_TreeView.InsertItem( strText );
m_TreeView.SetItemText( NewNode, strText );
ProcessMessages();
}
|
|
|
|
|
Found the problem
As I speculated it is the Scrollable property that is causing the problem
TreeNode NewNode;
treeView.Scrollable = false;
treeView.BeginUpdate();
for( int i = 0; i < 1000; i++ )
{
NewNode = treeView.Nodes.Add( "Node: " + i.ToString() );
NewNode.Text = "Node: " + i.ToString();
Application.DoEvents();
}
treeView.Scrollable = true;
treeView.EndUpdate(); Regards,
James
Simplicity Rules!
|
|
|
|
|
Hello All,
I'm getting a value from a registry key that is of type REG_MULTI_SZ and I can't display it on the screen. Consider the following:
Console.WriteLine(_remoteRegKey.GetValue("Foobar").ToString());
This is the output I'm getting:
System.String[]
Can anyone enlighten me as to how I can get the value of the key ? Thanks in advance...
-Koby
|
|
|
|
|
It passes back an array of strings. Try, iterating it and displaying them individually...
|
|
|
|
|
Not sure that this will work, but something like this might.
for(int i = 0; i < _remoteRegKey.GetValue("Foobar").Count; i++)
{
Console.WriteLine(_remoteRegKey.GetValue("Foobar")[i].ToString());
}
Someone please correct me if I am wrong. James, I know you are lurking out there.
Nick Parker
|
|
|
|
|
I think you'll need to use this code since GetValue() returns an object;
string [] values = (string []) _remoteRegKey.GetValue("Foobar");
for(int i = 0; i < values.Length; i++)
{
Console.WriteLine(values[i]);
} James
Simplicity Rules!
|
|
|
|
|
Thanks James, I had been up for countless hours last night due to those damn finals. That is all over now, so you don't have to worry about me posting incorrect information now. Sorry for any of those that I mislead.
Nick Parker
|
|
|
|
|
I would like to make winform has the same behavier as Microsoft windows does, when user press Ctrl+C, it will copy the selection into a clipboard, and can use Ctrl+V to paste it to somewhere. Anyone knows how to achieve it?
thanks
chris#
|
|
|
|
|
Nish has written an article on Code Project that should show you how to implement the Clipboard class in your application. Here is the link in a new window. Clipboard handling with .NET
HTH
Nick Parker
|
|
|
|
|
Great! It helps a lot! However, I still have a question in mind: how about copy an object array, and paste it to somewhere? I have a ListView control in a form, contains several objects. I want to be able to copy multiple of them, can I do it? And if their type is not listed in dataFormats list, how can I retrieve them? Thanks again!
Chris#
|
|
|
|
|
I'm finding that it would be very useful to have a class property that would accept multiple entries. For example, I want to have a property that keeps track of 5 toolbar buttons automatically for me. So, I want to create a property where I can automatically get/set the toolbar collection via the IDE.
The following code 'almost' works. The property appears, I can click on the "..." button and the Collection Editor appears, but it doesn't save anything. The word "(Collection)" doesn't appear in the property.
Are there any examples out there that show how to do this?
[Category( "Controls" )]
[Description( "Add the list of ToolBarButtons that keep track of the modes" )]
public ToolBarButton[] ToolBar_ButtonModes
{
set{ m_ToolBar_ButtonModes = value; }
get{ return m_ToolBar_ButtonModes; }
}
private ToolBarButton[] m_ToolBar_ButtonModes = null;
-- Thanks!!
|
|
|
|
|
Just a hunch, but usually if you want to tell the IDE something about your properties, you need to use Attributes. Maybe try the Designer attribute, and pass it the standard ToolbarButton[] designer (if such a thing exists). Or maybe there is a CollectionType attribute.
Just guessing
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
I know that Code Project has a *utility* for transforming code for articles into the correct color format. Has anyone seen/written a class to do this for the new .NET Framework, if not I am seriously considering this as a new project in C# (after the screensaver that is )?
Nick Parker
|
|
|
|
|
I want to create something similar to the C# Form Designer include in the C# IDE but not too advanced, I just want to know how can I lock a Form in my Main Application Window, anybody know how to make something like this ?
thanks.
BTW, is it possible to create a DLL with the other dll I need to create an application like System.DLL, System.Windows.Form.DLL all those DLL include in one So after I can only compile my program using this DLL ??? if yes how can I do this ?
Thanks Again
|
|
|
|
|
BLaZiNiX wrote:
I want to create something similar to the C# Form Designer include in the C# IDE but not too advanced, I just want to know how can I lock a Form in my Main Application Window, anybody know how to make something like this ?
From what I can tell the VS.NET forms designer actually loads the form up into a temporary app domain and displays it in the window. To display a Form inside another form use this bit of code.
Form childForm = GetFormToDisplay();
childForm.TopLevel = false;
childForm.Location = GetLocation();
this.Controls.Add(childForm); You'll also have to hook several messages using Application.AddMessageFilter so that the child form can't be moved around (NCHITTEST plus some WM_SYSCOMMAND).
I have another message here that explains how to use Application.AddMessageFilter
James
Simplicity Rules!
|
|
|
|
|
k i will try to code it, if I need help again I will post another msg
BTW do you know how can I (suppose I have a button control) remove some property in the PropertyGrid and replace it by my own. In my application, I add a propertyGrid and I want to show only some property for some controls, how can I do this ?
Thanks Again James
|
|
|
|
|
BLaZiNiX wrote:
BTW do you know how can I (suppose I have a button control) remove some property in the PropertyGrid and replace it by my own.
Without creating your own class derived from PropertyGrid you can't replace specific properties with your own.
The property grid shows all properties with a BrowsableAttribute set to BrowsableAttribute.Yes. So you could create your own psuedo-button class that encapsulates a Button, and pass that as the SelectedObject in the property grid.
James
Simplicity Rules!
|
|
|
|
|
I believe you will need to do a childForm.Show() on that also. The Forms framework doesn't seem to do it for you.
I used this technique a little while back to implement a Wizard97 look-a-like that allowed users to design their own forms and feed it to the primary Wizard form (sheet), all the wizard had to do was adjust a few properties and drop it into the mix, works well.
Regards
|
|
|
|
|
Neil Van Note wrote:
I believe you will need to do a childForm.Show() on that also. The Forms framework doesn't seem to do it for you.
LOL, yeah I always forget that; then wind up going over my code three times trying to find the bug
Simplicity Rules!
|
|
|
|
|
Every time...
|
|
|
|
|
do you think you can send me a sample code of something like your Wizard app ?
at this moment it's going well but I think I will have problem later
Thanks
Jonathan Pouliot
|
|
|
|
|
Well, if you follow James instructions above, it should do you pretty well. I really don’t feel right about releasing my code for this just yet, as it’s running in a current client’s system.
Just shout when you need assistance and one of us will push you in the right direction, or possibly someone reading this may have something similar that they are a little more free to share.
A word of caution up front though, in the current release of the .NET framework, forms created in this manner do not receive their OnClosing/OnClosed events naturally, and you should probably issue a Close on them manually when the container form receives its notification. A second solution, which I used, was to issue a custom set of Wizard related events to signal that the parent was about to close and it was time for the form(s) to cleanup. Using this method protects my code from issuing a second Close, just in case the boys and gals over at MSFT decide to fix the issue. The dispose methods do get called regardless.
Regards
|
|
|
|
|
the only thing it's after the user create the form dynamicly I want to include action on some controls like buttons and I want to compile all the form with the controls action in one file *.cs and after compile it to an exe.
What I want to know it's how can I create the CS file to add the action and the form design in, like VC# does ?
Thanks
|
|
|
|
|
My wizard solution is something used by the clients developers, so it is more of a component than an application builder.
Just out of curiosity, and I am definitely not the one that would try to stifle your ambition, but why are you trying to reinvent the wheel that was just built?
It would seem to me that if you expose a good object model, extending an application built with .NET would be trivial without all of this, just having the clients developers use .NET to build extensions. Or are you looking for a mini environment like VBA in outlook?
Regards
|
|
|
|