Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > Pro VB.NET 2002/2003
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 14th, 2003, 05:41 AM
Authorized User
 
Join Date: Jun 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default default properties on controls

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
__________________
Duncan
 
Old November 14th, 2003, 03:50 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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.
 
Old November 15th, 2003, 01:55 PM
Authorized User
 
Join Date: Jun 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old November 15th, 2003, 02:32 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding properties to controls pauliehaha ASP.NET 3.5 Basics 0 June 23rd, 2008 04:56 AM
Default settings for Tool Bar, Properties, etc. KKeesling Visual Basic 2005 Basics 1 April 4th, 2006 02:46 PM
Access templated controls properties tony_j_hug ASP.NET 2.0 Basics 5 October 17th, 2005 10:44 AM
Accessing Properties in User Controls andyj00 ASP.NET 1.0 and 1.1 Professional 16 August 1st, 2005 07:55 AM
Accessing Properties in User Controls andyj00 Classic ASP Professional 1 May 21st, 2005 02:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.