Subject: default properties on controls
Posted By: Duncan Post Date: 11/14/2003 4:41:19 AM
Hi

I am modifying a text box to include different color backgrounds when the control recieves focus and if the value changes, change the color again when the control looses focus. My question is when I add a text box to a user control project I can see standard properties like Readonly, MultiLine, Accepts Tab etc, but when I compile the control and add it to a project none of these properties are visible, I assume I would need to expose these properties using a public property get/set.
I suppose my question is why aren't these properties exposed by default, they would be if I added the text box to the app without creating a user control so why not when adding to a user control.

Or have I missed some coding switch that enables all these properties?



Duncan
Reply By: planoie Reply Date: 11/14/2003 2:50:42 PM
The textbox is inside the user control.  Its properties are visible within the user control's scope.  But because the textbox is protected or private, you can't access its properties from outside the control.

You could either A) make the textbox public on the user control or B) provide public properties on your user control that access the properties of the protected/private textbox.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply By: Duncan Reply Date: 11/15/2003 12:55:13 PM
Hi Peter, thanks for the reply.

Question how do you make the text box public on the user control? I've tried changing the most obvious options but to no avail,
can you point me in the right direction with this. I know the other option would be to expose the properites I want which I have done, but to me it seems I'm duplicating code and could be introducing errors.

Duncan
Reply By: planoie Reply Date: 11/15/2003 1:32:58 PM
In the code for the control, where the textbox is declared, it should be declared with one these keywords : Private or Protected.  I don't work with windows forms much so I don't know the default.   But regardless, you need to change it to Public.  This will make the textbox accessible outside the control.  Usually, it's better to expose only what you need with some public properties on the user control that access the internal control instead of just exposing the whole internal control itself.

Peter
------------------------------------------------------
Work smarter, not harder.

Go to topic 6528

Return to index page 1004
Return to index page 1003
Return to index page 1002
Return to index page 1001
Return to index page 1000
Return to index page 999
Return to index page 998
Return to index page 997
Return to index page 996
Return to index page 995