RE: Object Name
From: Carl (Carl_at_discussions.microsoft.com)
Date: 07/09/04
- Next message: Francesco: "XSL + PocketPC"
- Previous message: Carl: "RE: Object Name"
- In reply to: Carl: "RE: Object Name"
- Next in thread: Chris Tacke, eMVP: "Re: Object Name"
- Reply: Chris Tacke, eMVP: "Re: Object Name"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 9 Jul 2004 10:02:01 -0700
The code I found on this board does not work, any idea why ?
It returns the error,
An unhandled exception of type 'System.NullReferenceException' occurred in System.Windows.Forms.dll
at line ,
if(f.GetValue(((Control)SourceControl).Parent).Equals(SourceControl))
return f.Name;
The object I pass to it is a textbox from a pageframe.
-------------------------------------------------------------------------------------------
public static string GetControlName(object SourceControl)
{
FieldInfo[] fi = ((Control)SourceControl).Parent.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance |
BindingFlags.Public | BindingFlags.IgnoreCase);
foreach(FieldInfo f in fi)
{
if(f.GetValue(((Control)SourceControl).Parent).Equals(SourceControl))
return f.Name;
}
return null;
}
"Carl" wrote:
> See this link for a fix.
>
> http://blog.opennetcf.org/ctacke/PermaLink.aspx/64c28b10-d3a8-4c6b-b11a-2ae2de4bdaf1
>
> "Carl" wrote:
>
> > Is there a way in the PPC2002 and Compact Frame Work to figure out the name of an object pass to a function?
> >
> > It seam there is no name properties.
> >
> > Example :
> > -----------------------------------------------------------------------------------------------
> > public void SetDataInputField(TabPage ObjTabReceive)
> > {
> > foreach(Object myOBJ in ObjTabReceive.Controls)
> > {
> > if (myOBJ is System.Windows.Forms.TextBox)
> > {
> > TextBox fieldToValidate = (TextBox) myOBJ;
> > if(fieldToValidate.Name = "txtHours")
> > {
> > // do some treatments
> > }
> >
- Next message: Francesco: "XSL + PocketPC"
- Previous message: Carl: "RE: Object Name"
- In reply to: Carl: "RE: Object Name"
- Next in thread: Chris Tacke, eMVP: "Re: Object Name"
- Reply: Chris Tacke, eMVP: "Re: Object Name"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|