Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / April 2008

Tip: Looking for answers? Try searching our database.

Can't determine correct type at runtime

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Fuller - 20 Apr 2008 17:50 GMT
I am trying to determine the type for ActiveControls using 3rd party
controls (Infragistics in this case) during runtime and getting a rather odd
return type at runtime for the UltraWinEditor.

Code shippet is as follows:

if ( ActiveControl.GetType() == typeof(UltraTextEditor))
{
   UltraTextEditor tb = (UltraTextEditor) this.ActiveControl;
   if (tb.Multiline == true)
       return true;
}

I am expecting to see an UltraTextEditor for the ActiveControlType but,
instead, getting "Infragistics.Win.EmbeddableTextBoxWithUIPermissions", so
the "if" statement fails on the control.

If I modify the "if" statement to: "if (ActiveControl.GetType().ToString()
== "Infragistics.Win.EmbeddableTextBoxWithUIPermissions")", the subsequent
cast fails.

Does anyone know what would cause the control type to be different at
runtime than what it was built from?

(BTW, the test form is ONLY using UltraTextEditor controls, so the type
should be the same for each.)
Lasse Vågsæther Karlsen - 20 Apr 2008 18:04 GMT
> I am trying to determine the type for ActiveControls using 3rd party
> controls (Infragistics in this case) during runtime and getting a rather odd
[quoted text clipped - 22 lines]
> (BTW, the test form is ONLY using UltraTextEditor controls, so the type
> should be the same for each.)

I'm going on assumptions here, but judging by the full name of that
control, I'd say you have focus to the editor, but it is actually
similar to a user control and what you're reading there is an embedded
editor inside what dropped on the form.

DevExpresses uses the same approach, with something like a
RepositoryTextEdit, which is then used internally in both grids and
normal droppable edit controls. I don't know if the DevExpress controls
would give me the same behavior as you're seeing though.

In any case, it's just a guess. I guess the best way to get a concrete
answer would be to ask the Infragistics guys about this.

Let me pose another question... What specifically are you trying to
accomplish with the code? Perhaps there's a different way to do what you
want to do than the one you're currently trying.

Signature

Lasse Vågsæther Karlsen
mailto:lasse@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3

Bill Fuller - 20 Apr 2008 23:18 GMT
>> I am trying to determine the type for ActiveControls using 3rd party
>> controls (Infragistics in this case) during runtime and getting a rather
[quoted text clipped - 40 lines]
> accomplish with the code? Perhaps there's a different way to do what you
> want to do than the one you're currently trying.

It sounds like you are pointing me in the right direction as to the source
of my problem. I did post the question to Infragistics, but need to find an
answer ASAP, if possible, and I have found them to be rather slow in
responding.

What I am trying to do (and it is working for the most part) is set a global
hook via IMessageFilter to convert the ENTER key to a TAB key for the entire
application, which is largely data entry type forms. However, I have also
set a virtual method for this that can be overridden in instances where the
Enter key on a particular form needs to be processed rather than use the
default, such as in the case where a multiline textbox that allows Enter key
handling may be on the form... or perhaps a button key. This code would
process the override if I can get it to work... was taken by surprise with
the type return as a standard Microsoft textbox works as expected.
Gilles Kohl [MVP] - 20 Apr 2008 18:31 GMT
>I am trying to determine the type for ActiveControls using 3rd party
>controls (Infragistics in this case) during runtime and getting a rather odd
[quoted text clipped - 22 lines]
>(BTW, the test form is ONLY using UltraTextEditor controls, so the type
>should be the same for each.)

Hmm, could it be that UltraTextEditor is a composite control,
containing an Infragistics.Win.EmbeddableTextBoxWithUIPermissions at
runtime?

As the latter seems to be derived from TextBox according to:

http://help.infragistics.com/Help/NetAdvantage/NET/2008.1/CLR2.0/html/Infragisti
cs2.Win.v8.1~Infragistics.Win_namespace_hierarchy.html


what you could do instead of your if block above is this (untested):

  TextBox tb = ActiveControl as TextBox;
  if(tb != null) {
     if(tb.Multiline) {
        return true;
     }
  }

  Regards,
  Gilles.
Bill Fuller - 20 Apr 2008 23:35 GMT
>>I am trying to determine the type for ActiveControls using 3rd party
>>controls (Infragistics in this case) during runtime and getting a rather
[quoted text clipped - 43 lines]
>   Regards,
>   Gilles.

Your untested code fix did the trick...thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.