|
Hi,
I have created a custom grid class which inherits from the DataGrid class.
Using reflection i want to invoke on of the private method of the base class. Am able to list all the public method, but not able to get the refernce to the private methods. Attached is the class am using.
<br />
public class CustomDataGridTest : DataGrid <br />
{<br />
<br />
<br />
private DataTable PopulateTable()<br />
{<br />
DataTable dt = new DataTable();<br />
dt.Columns.Add("Name");<br />
dt.Rows.Add(new object[] {"John"});<br />
dt.Rows.Add(new object[] {"Miller"});<br />
dt.Rows.Add(new object[] {"Lara"});<br />
dt.Rows.Add(new object[] {"Tommy"});<br />
dt.Rows.Add(new object[] {"Robin"});<br />
return dt;<br />
}<br />
<br />
public MethodInfo GetMethodInfo()<br />
{<br />
this.DataSource = PopulateTable();<br />
<br />
MethodInfo mi = base.GetType().GetMethod("get_DataGridRows", <br />
BindingFlags.FlattenHierarchy | BindingFlags.IgnoreCase | BindingFlags.Instance <br />
| BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); <br />
return mi;<br />
}<br />
}<br />
Can anyone tell me as why the GetType().GetMethod() not returning the methodinfo object. It always return null.
Thanks in advance for any kind of help
Regards,
Kais
|
|
|
|
|
Because you have to use GetProperty() method to retrieve a property.
Best regards,
-----------
Igor Sukhovhttp://sukhov.net
|
|
|
|
|
Igor,
I dont see any such property to reterive the get datagrid rows collection.
Is there any alternate way to reterive that.
Regards,
Kais
|
|
|
|
|
First, what is the type of your datagrid ? Are you absolutely sure that this particular datagrid class have a method with the "get_DataGridRows" name ?
Best regards,
-----------
Igor Sukhovhttp://sukhov.net
|
|
|
|
|
Hi ,
Am using windows form datagrid. The datagrid class has a private method named get_DataGridRows. This method will hold the DataRow collection of the datagrid. Since am inheriting the Datagrid class am not able to access this method. If i use it directly am able to access it.
Regards,
Kais
|
|
|
|
|
Windows Forms datagrid do have internal DataGridRows property and get_DataGridRows method is the get accessor for this property.
It's recomended to retrieve property value by obtaining a PropertyInfo object first and calling GetValue method on that object.
Best regards,
-----------
Igor Sukhovhttp://sukhov.net
|
|
|
|
|
Hi......
Can anyone please tell me how to get a handle to a window outside the C# running application? if i drag and drop an icon on a window outside an application, how do i get its handle? anyone..please help me. i'm in a fix...
Thank You...
SB
|
|
|
|
|
You must use Win32API to do that. Probably this is the right function:
http://www.pinvoke.net/default.aspx/user32/GetWindow.html
|
|
|
|
|
Hi
I am just wondering how I would arrange things in a resource file. For example I want to add options under dropdown combo boxes in a resource file and read them from there - for doing this am i supposed to make a new resource file for each dropdown or add them in same one - but this way how do i identify which ones belong to which file.
If i add them as strings and give them names like Combobox1_Option1, Combobox1_Option2 .... and so on? then how do i get these out?
thanks for your help
|
|
|
|
|
Hello
UnderWing wrote: but this way how do i identify which ones belong to which file.
Naming convention is totally up to you. I don't see a problem there!!
UnderWing wrote: then how do i get these out?
Using the ResourceReader class -but I assume you already know that- again I can't see your problem?!!
Please post more details concerning your problem, maybe I can help you then
Hints:
Why don't you add them all to one file and give them prefixes just like yoiu said??
Even why not put them in an XML file, or your app config file?? If it's not all about resources.
Regards
|
|
|
|
|
Hi
I am dynamically populating a TreeView using the method:
protected void TreeView1_TreeNodePopulate(object sender, TreeNodeEventArgs e)
{
}
but the problem is: e.Node.Parent is *ALWAYS* null even if I click on leaf and non root nodes! any idea why?? The ValuePath string is correct and the Depth property is also always correct but Parent will always be NULL! this has me totally stumped.
any ideas? I wasted like 2-3 hrs debugging other code for this but then finally found this to be the case and am using the ValuePath to determine the root node now
(please reply here, do not send me an email thanks)
|
|
|
|
|
I have created a very simple login dialogbox for my application. If credentials are good the main form is displayed. How can I used the same dialog box on another application without rebuilding it from scratch again?
I tried to import the second form (form2.cs) in the project but compliains about the namespace.
any help is grealy appreciated
|
|
|
|
|
|
Hello, I've found an article on here that describes how to mask keyed in characters for inputting passwords:
ConsolePasswordInput[^]
At the bottom of this article it states that it's an application (obviously) but it can be easily converted into a library. I'd love to convert it into a library but I have no idea how to do this.
I'm relatively new to C#. I'm currently running MS Visual Studio 2005 with .Net Framework 2.0
I was thinking I could start a new Class Library project and just paste in the required code, but I believe that will create a .dll file. I believe that once my application makes use of this library it will have to register itself, and I was trying to avoid having my application register anything.
If anyone is able to help or even just point me in the right direction, I would greatly appreciate it. Please let me know if you need anymore information!
|
|
|
|
|
A Class Library project will produce a DLL. By registering, I assume you're talking about registering the DLL to the GAC... Which isn't necessary. You can create a new class library project, and paste in the necessary code. Then have your application reference that DLL (or project if you have both projects in the same solution) to use the classes in the library.
If you don't want to do that, you can paste the necessary code into your application's project instead, which will work just the same, it just won't be usable by other projects.
Does that help?
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
You are correct that it would create a .dll. You dont have to register it, however, unless you want to, but is usually unnecessary unless you plan on a lot of apps accessing it. Just compile the dll and add a reference to it in your projects. It will be copied and distributed with your app (in the app folder) without registering.
If you do decide to register your dll, just create a strong name with the sn.exe utility (from the .NET SDK command prompt) to create a key pair, then assign that to your [assembly:KeyName] attribute of the .dll (assemblyInfo.cs/vb). Then recompile and use gacutil.exe (.NET SDK command prompt) to register the dll in the GAC. Only do this if it is absolutely necessary, however.
HTH.
Aaron Dilliard
|
|
|
|
|
Thank you both for your help - I'm going to give this a try tomorrow
Now that I know a dll doesn't have to be registered, it should all be ok!
|
|
|
|
|
Just thought I'd let you all know that I managed to get the library working successfully. Thank you for all your help
|
|
|
|
|
On many of my applications I make use of a ListView control, that has a certain color displayed on the column that is currently sorted. It also highlights rows for special things. In .NET 1.1 this worked perfectly, but whenever I try to import an app into .NET 2.0 (VS 2005) the color highlights only show up when the form loses focus and gets it back. If you scroll, the items lose the color. This also happens when the SelectedIndex changes and the highlight is given to a new row. The previously selected row loses color. As I said before, the only way to get back the color is for the form to lose focus and regain it. Is the ListView drawn differently in .NET 2.0? Anyone else had this issue? Thanks in advance
Aaron
|
|
|
|
|
Aaron Dilliard wrote: Is the ListView drawn differently in .NET 2.0?
I don't think there are any major changes that would break an app.
Aaron Dilliard wrote: Anyone else had this issue?
Nope
My guess is that you're not handling it as well as you could be. Are you deriving from the ListView control and overriding the OnDrawItem method or are you handling the events. If you're handling the events I'd try overriding the method in a custom control.
Sorry I'm not of any further help
|
|
|
|
|
I agree that there are no major changes that would break an app, but even subtle changes in the way the control is drawn could have an effect on 1.1 code. IE, if a WM_PRINT message is sent with the ERASEBACKGROUND flag or something like that, that could be the culprit. I know Microsoft changed the control some in 2.0, and Ill bet that is what is going on. I will just have to rework the code. Thanks for the input.
Aaron
|
|
|
|
|
I have a dll I wrote.
It contains comments and summaries (XML summaries if I'm not mistaken)...
After compiling the dll, and referencing it in another project, summaries are never shown...
Is it possible not to lose them after compiling the dll?
How exactly?
Thanks,
Shy.
|
|
|
|
|
XML comments are never included in the compiled assembly. If you want to see your comments as hints in another project complie your dll with /doc directive (or set "XML documentation file" project property). And always keep generated xml-file close to your dll.
|
|
|
|
|
Hello
If you mean the ///summary block the precedes methods and properties, then the problem would be in your syntax because it should appear as a tooltip when you try to use the methods of your referenced dll.
Post an example of a method's signature that your wrote with its summary, maybe we can come up with something.
Regards
|
|
|
|
|
It should appear only when dll and client application are in one solution. Comments are not metadata and compiled assembly doesn't contain them. So none can show these comments as tooltips (even VS ).
To see the problem just create a simple dll and then make reference on it from another solution. You won't see your XML-comments in tooltips until you generate xml-file with /doc for your dll.
For more information see this article in MSDN Magazine.
|
|
|
|