|
You can ask every object for its type with .GetType() . You get back a Type object. It has methods on it such as GetMethod , GetProperty and so on. You can get information from the objects those methods return MethodInfo or PropertyInfo and so on. If you find the one you want you can then Invoke it.
Most of this should make enough sense through intellisense. You may have to look up some stuff in the documentation though. It really is worth reading up on so you have a better understanding of the environment in which you are working.
|
|
|
|
|
Thanks, I'll check it out.
|
|
|
|
|
Don't you think, that this would bring a lot of useless matches (ListBox.Items).
I think it would be easier to check out how many control classes don't match "Controls", and do a typecheck ("as") at them!
All the best,
Martin
|
|
|
|
|
Martin# wrote: Don't you think, that this would bring a lot of useless matches (ListBox.Items).
Since I don't know what the overall purpose is I can't say if that would bring lots of useless matches or not. It might do. It might not.
|
|
|
|
|
The Overall purpose is to have a dictionary that will map a Gui object to a bitmask to determine its accessibility to each user of the application
|
|
|
|
|
I wouldn't use reflection. I'd just test if the current control is of a type with a property Controls or whether it is of for example type ToolStrip:
Or the make the code more readable, introduce several overloaded methods that take the different types as a parameter (one overload for control, one for toolstrip, ....)
And call them recursively.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
Do not forget to check the HasChildren property. Speeds things up.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
That may depend on how the enumeration is implemented.
|
|
|
|
|
Iterate over the Controls collection.
|
|
|
|
|
by looping through all children of the MainForm and their children and so on.
You can use either recursion or a Stack algorithm.
To get the children use the Controls property of a Control.
To speed things up use property HasChildren to check if a Control has childrens.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
As I said
I need not cycle over the controls only.
For Ex:
Assuming ther is a Control Within the Form of Type - ToolStrip
The ToolStrip Class has no Controls Property
Its Childeren are Beeing held in a collection which can be accessed with the Items Propery
- Now - to get to them I cannot do what u have all mentioned above.
So... my Question Remains - how can this be done?
|
|
|
|
|
Iterate like people have said, but check the type of the object, and run a separate peice of code to get its items collection, or its child controls etc.
Whatever you do, im pretty sure there isn't some simple function you can use, its gonna take quite the chunk of code, and your probably gonna have to write it all yourself.
|
|
|
|
|
you go to hell.............
|
|
|
|
|
Whould you mind explaining yourself?? Undefeated's explanation and suggestion is perfectly valid.
|
|
|
|
|
but it wasn't something that could be copy/pasted as is to do the OPs homework/job for him. Consequently it was worthless.
--
If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.
|
|
|
|
|
Hi, I wrote a Schema Validator in C#.NET.
XmlTextReader R = new XmlTextReader(FileToParse);
XmlValidatingReader V = new XmlValidatingReader(R);
try
{
XmlSchemaCollection xsc = new XmlSchemaCollection();
xsc.Add("", SchemaFile);
V.Schemas.Add(xsc);
V.EntityHandling = EntityHandling.ExpandEntities;
V.ValidationEventHandler += new ValidationEventHandler(ShowValidationErrors);
while (V.Read())
{
}
//V.Close();
//MessageBox.Show("Validation Completed");
//R.Close();
}
catch (XmlException xe)
{
//Display exceptions
}
catch (XmlSchemaException xse)
{
//Display exceptions
}
catch (Exception ee)
{
//Display exceptions
}
finally
{
V.Close();
MessageBox.Show("Validation Completed");
}
This works fine if the xml file DOES NOT contain entity declarations.
But, If the xml file contains any entity declaration (as below), the 'ValidationEventHandler' throws errors like
"Validation Error: The 'mytest' element is not declared.Line : 8 Position : 2"
"Validation Error: The 'articles' element is not declared.Line : 9 Position : 2", etc.....
How do I overcome this in C#.NET
]>
<mytest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nonamespaceschemalocation="X:\Schema\content.xsd">
|
|
|
|
|
just like using vs2003 ... thanks very much...
|
|
|
|
|
kkun wrote: just like using vs2003 ... thanks very much...
What was the point of that post?
|
|
|
|
|
Create a new project of type "Class Library"
Code pre-built is code that you don't have to build later.
|
|
|
|
|
|
No problem! Glad to help!
Code pre-built is code that you don't have to build later.
|
|
|
|
|
kkun wrote: just like using vs2003 ... thanks very much...
Aahhh - that's nice. I'm so pleased for you.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
hi
i'm using c#.net 2005 and mssql 2005 express edition and developing a automation program.
i wanna update customers database(anywhere) via internet on my server(my office) like an antivirus program. when customer run my application program, then start to checking of database updates and if its necesseray update it.
i haven't any idea for do this.which feature will helpfull to me?
(it will be another program which is running when the operating system starts.it will be another programming language.)
how can i solve this.
murat
|
|
|
|
|
maybe WebServices, http://www.codeproject.com/cs/webservices/
VirtualVoid.NET
|
|
|
|
|
Is it possible to display images from web by URL?
As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality.
Albert Einstein
|
|
|
|