Problem setting SLXTextbox enabled property / Setting unexposed base control properties for a custom control

 I recently had an issue with a Quickform where I was attempting to set the Enabled property of a TextBox based on the value of a checkbox on the same form.  For some reason, the enabled property I was setting for the textBox was not being honored.  My code was basically this:

if (checkbox.checked)

{

   checkbox2.Enabled = false;

   textBox.Enabled = false;

}

else

{

   checkbox2.Enabled = true;

   textBox.Enabled = true;

}

I never did figure out why this particular TextBox’s property was behaving this way, but I thought I’d try setting the Readonly property instead.  One problem with this though… the Saleslogix TextBox control (which is a custom control) does not have a Readonly property exposed.  A standard TextBox control does, however.  Since the Saleslogix TextBox is derived from a standard TextBox, I was able to set that property by casting the control as a standard TextBox.  I did this by replacing the line:

textBox.Enabled = true;

to

((TextBox)textbox).ReadOnly = false;

I’m still not sure why the Enabled property didn’t work in the first place, but setting the ReadOnly property did work instead.  The ReadOnly property won’t show up in the Intellisense, but if you are sure of the derived control type property names, this should work for other controls as well.

Thanks for reading!

ABOUT THE AUTHOR

Jason Buss

Jason is a senior application developer with Customer FX.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) news and product updates!

You have Successfully Subscribed!