473,503 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Do controls have to be private?

Hi

I am using VC++.net 2003. Whenever I place a control on a winform, it is declared as private. Then I have to write set and get methods to access these controls from a calling form. Why are they declared private instead of public? Does it hurt to change them to public? It seems like it would be much faster to set/get properties directly

Thank you
Joe
Nov 17 '05 #1
3 951
Hi Joe,

Well it would break your class encapsulation. IMO this would be a great
first step towards creating a bunch of spaghetti objects if thats what you
want.

Cheers

Doug Forster

"Joe Thompson" <an*******@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
Hi,

I am using VC++.net 2003. Whenever I place a control on a winform, it is declared as private. Then I have to write set and get methods to access
these controls from a calling form. Why are they declared private instead
of public? Does it hurt to change them to public? It seems like it would
be much faster to set/get properties directly.
Thank you,
Joe

Nov 17 '05 #2
Joe,
As Doug stated, it would break encapsulation.

I would recommend only adding a Get property, as generally you really do not
want classes outside the form to change the instance of the control. Also I
rarely expose the control itself as a property, normally I only expose one
or two properties of the control as properties of my form.

For example, my form would have a get/set String property for FirstName,
that modified the Text property of the FirstNameTextBox control. The other
properties of the FirstNameTextBox I want to be under 100% control of the
form itself.

Hope this helps
Jay

"Joe Thompson" <an*******@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
Hi,

I am using VC++.net 2003. Whenever I place a control on a winform, it is declared as private. Then I have to write set and get methods to access
these controls from a calling form. Why are they declared private instead
of public? Does it hurt to change them to public? It seems like it would
be much faster to set/get properties directly.
Thank you,
Joe

Nov 17 '05 #3
Hi

Thanks for your replies. I understand what you're saying. The only thing I want to do is to set values before I show the dialog and get them back after OK is selected. Some things are textboxes, radio buttons, numericupdowns, etc. I guess I'm just getting lazy. In Borland C++ Builder I believe the controls are "published" which allowed access from outside

Joe
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3491
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
3
14140
by: Chris | last post by:
Hi, I'm trying to append text from another class to a generic richTextBox that I've added to a Windows form. I can't seem to figure out how to expose the richTextBox to append text to it. ...
3
2627
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
1
3136
by: sleigh | last post by:
Hello, I'm building a web application that will build a dynamic form based upon questions in a database. This form will have several different sections that consist of a panel containing one to...
4
2077
by: Bass Pro | last post by:
Hi, I am creating textbox, radiobuttonlist and checkboxlist dynamically depending on data from a table. It is a questionnaire. I add the control on a Panel control during the 1st load_page event....
0
2265
by: jonelling | last post by:
I am having a problem where the page load event is not being fired for certain user controls that I load dynamically in placeholders. Here is what I'm doing in brief, with full test code supplied...
11
2110
by: VJ | last post by:
I am looking to have 2 Tab Controls on a Windows Forms.. One with Tabs on Top and another with Tabs on the side... I want them both to occupy the entire area of the form, but I need the Tab...
0
2385
by: Mike Collins | last post by:
I someone can please help, I am about at an end in trying to figure this out. I am adding some dynamic controls to my page (I found out that I was supposed to be doing that in the oninit event,...
1
2018
by: Martin | last post by:
Hi all ! I use Visual Studio .NET 2005 SP1 (+ Updates for Vista) on Windows Vista. I have a strange problem in a WinForm application. In a UserControl, which inherit another UserControl...
5
1435
by: Paul Hemans | last post by:
Hi, I am using VS2005. I have a form with a tabControl on it. Suddenly I can no longer see any of my controls, on any of the pages, or even the tabControl itself. They still exist because the...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.