By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,166 Members | 1,775 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,166 IT Pros & Developers. It's quick & easy.

Can't determine correct type at runtime

P: n/a
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.EmbeddableTextBoxWithUIPermissio ns", so
the "if" statement fails on the control.

If I modify the "if" statement to: "if (ActiveControl.GetType().ToString()
== "Infragistics.Win.EmbeddableTextBoxWithUIPermissio ns")", 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.)
Jun 27 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Bill Fuller wrote:
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.EmbeddableTextBoxWithUIPermissio ns", so
the "if" statement fails on the control.

If I modify the "if" statement to: "if (ActiveControl.GetType().ToString()
== "Infragistics.Win.EmbeddableTextBoxWithUIPermissio ns")", 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.)

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.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
Jun 27 '08 #2

P: n/a
On Sun, 20 Apr 2008 09:50:57 -0700, "Bill Fuller" <so*****@nospam.com>
wrote:
>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.EmbeddableTextBoxWithUIPermissio ns", so
the "if" statement fails on the control.

If I modify the "if" statement to: "if (ActiveControl.GetType().ToString()
== "Infragistics.Win.EmbeddableTextBoxWithUIPermissio ns")", 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.)
Hmm, could it be that UltraTextEditor is a composite control,
containing an Infragistics.Win.EmbeddableTextBoxWithUIPermission s at
runtime?

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

http://help.infragistics.com/Help/Ne...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.

Jun 27 '08 #3

P: n/a
"Lasse Vågsæther Karlsen" <la***@vkarlsen.nowrote in message
news:Oa**************@TK2MSFTNGP06.phx.gbl...
Bill Fuller wrote:
>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.EmbeddableTextBoxWithUIPermissio ns",
so the "if" statement fails on the control.

If I modify the "if" statement to: "if
(ActiveControl.GetType().ToString() ==
"Infragistics.Win.EmbeddableTextBoxWithUIPermissi ons")", 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.)


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.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
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.
Jun 27 '08 #4

P: n/a
"Gilles Kohl [MVP]" <no_email_available@wrote in message
news:0l********************************@4ax.com...
On Sun, 20 Apr 2008 09:50:57 -0700, "Bill Fuller" <so*****@nospam.com>
wrote:
>>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.EmbeddableTextBoxWithUIPermissio ns", so
the "if" statement fails on the control.

If I modify the "if" statement to: "if (ActiveControl.GetType().ToString()
== "Infragistics.Win.EmbeddableTextBoxWithUIPermissio ns")", 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.)

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

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

http://help.infragistics.com/Help/Ne...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.
Your untested code fix did the trick...thanks.
Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.