|
I looked at the code, and it pretty much looks like my code.
Is there anyplace I can look at the equivalent C++ code that Chris timed?
|
|
|
|
|
If you installed vs.net, you can find C# language sepecification document on VC# folder, and also you can find many resource on msdn online.
I'm amumu, and you?
|
|
|
|
|
Hello All,
I have a component (say AManager) managing a set of custom controls (say AView) as standard collection on .NET form.
A property of the AManager (Views) displays the collection editor dialog with the "Add" and "Remove" buttons.
Now, the problem is, the "Add" button adds a new AView object to the collection and the necessary code is generated in the Form file. However, the code which will add the custom control to the form is not generated and therefore the control does not appear on the form. I had to manually update this part.
ie. the following line in the form source is not updated
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.customControl12,
this.customControl11});
when I use the collection editor to add customControl13 to the collection. So, I have to manually add the line as:
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.customControl13,
this.customControl12,
this.customControl11});
Any help? Am I missing some attributes?
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
How do I iterate through a collection while modifying it?
Let's say I have a hashtable I want to clear one entry at a time. I might want to retrieve an object from the table and do something with it before I remove it.
I can not use the foreach statement on the dictionary entries in the table without getting an exception. I've understand that enumerators work the same way. The remove method is no good either since it does not return what it removes.
How can I solve this problem as easily as possible? Any hints would be much appreciated.
Thanks!
|
|
|
|
|
J. Ehrnström wrote:
I can not use the foreach statement on the dictionary entries in the table without getting an exception. I've understand that enumerators work the same way.
Actually that is the same thing Underneath it all foreach just uses enumerators to iterate through the collection.
What I would do is to get the collection of keys, then iterate through that; to remove what you need to.
Hashtable table = .....;
object [] keys = new object[table.Keys.Count];
table.Keys.CopyTo(keys, 0);
foreach(object key in keys)
{
object obj = table[key];
} HTH,
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
Thanks for your quick reply. I tried your solution and it worked just fine.
I actually did think about adding the keys to their own list using an ArrayList, but that list would only have referenced the original keys, so the problem would have remained. You solved that problem by explicitly copying the keys.
Thanks again!
|
|
|
|
|
You an encapsulate this in a class, which then allows you to write:
foreach (MyClass c in new IterIsolate(arr))
{
}
I did a column on this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp01212002.asp
|
|
|
|
|
Thanks for the tip. Your sample was right on target.
|
|
|
|
|
I am working on a C# wrapper for the XML Document schtuff. I am also writing a GUI that nicely formats my XML, etc. The idea is that I have a couple of edit boxes, a combo and a button. When you push the button, the parameters in the two edit boxes get passed to the function selected in the combo. I am wondering if by reflection, or any other means, I am able to call the method I want to, by having it's name as a string ? Currently I have a big old switch statement, but that seems far cooler and a chance to play with something that has no C++ equivelant I know of, assuming it does what I think it does.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
yes, you can do that just fine with reflection.
You just have to know the Type which the method belongs to.
call Type.InvokeMember on it, passing the method name, object instance, and args.
you can also get the Type from a string via Type.GetType.
|
|
|
|
|
So if I have a member object called m_XMLDoc, and it contains methods that are in my combobox, I can get the method selected as a string called sMethod, and do something like
m_XMLDoc.InvokeMember(sMethod, new Array(sArg1, sArg2));
???
I am sure the syntax is wrong, I'm just clarifying that I have the general idea right.
Thanks for helping.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
the idea is right, but yes, the syntax is wrong.
you call InvokeMember on the System.Type class, not the instance itself.
if you have the instance handy... you can do
m_XMLDoc.GetType().InvokeMember(sMethod, new Array(sArg1, sArg2));
but I believe that you'll need to pass the instance back in as an arg as well, because you call it from the Type not the instance.
|
|
|
|
|
Cool. Now that I know that it's worth looking, and what I am looking for, I am sure that 'Inside C#' will fill the gaps for me.
Thanks again.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
hello to all,
not to long ago, there was an article on this site about Load balancing in a Mult tier scenario using remoting.
http://www.codeproject.com/info/error404.asp?404;http://www.codeproject.com/useritems/Multitier.asp
this no longer exists. i'm curious if anyone out there either kept a copy of the code from this article or has a method in doing this.
i've got my ntier going (using Remoting) and would really like to balance the servers.
thanks,
Orion
|
|
|
|
|
I need to get to a certain posistion in a remote file [online], but i do not want to download all of the bytes that arenot after the point in the file i want to download from.
any help.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
I've downloaded Compuware's DevPartner "community" edition profiler. However, what I'm really looking for is a 3rd party dev utility that will trace my C# method calls as the app is exercised, trace the parameters passed to each method (list their values), print the trace, etc.
Does such a tool exist and where may I find it if it does exist?
Thanks very much.
|
|
|
|
|
I saw a small util called TraceHook somewhere here on CodeProject or somewhere else maybe. Mite be helpful.
READ MSDN
|
|
|
|
|
Thanks, leppie. I'll search for TraceHook.
|
|
|
|
|
Hi! I've got these strings that have \r\n's in them. I wanted to know if there is a way to remove them from the string using the .NET regular expression engine, instead of StringBuilder.
Thanks and sorry about the double-post.
|
|
|
|
|
Hi, wouldn't a string.Replace("\r\n", "") work?
READ MSDN
|
|
|
|
|
Whoa! So easy! Thanks a lot. I was doing something really wierd.
|
|
|
|
|
Thats why I have not ventured in Regex Land
But I have to now, strings are just getting too complicated.
READ MSDN
|
|
|
|
|
Hi, how i can implement file drop operation between TreeView and ListView? Thanks.
|
|
|
|
|
Hi everybody!
Am I just stupid or isn't there any clean way to disable a whole tab page (with the effect, that the "tab" of the page is greyed and it can't be selected)? Or is it not advised to do so?
Cheers
TIA
Martin
[Edit]
Ok, Ok it inherits from control and therefore has an "Enabled" property although this is neither listed in the docs nor present in the designer or intelli sense....
Oh wait! Of course it's not listed because it doesn't do anything useful!
[/Edit]
"Situation normal - all fu***d up"
Illuminatus!
|
|
|
|
|
plz plz plz help me.
someone out there must know how to rename a file. thats is the only thing standing in the way of my class. i had a look on msdn but could not find what i was looking for.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|