Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
GeneralRe: Simple Reflenction Pin
afronaut24-Aug-04 8:33
afronaut24-Aug-04 8:33 
GeneralGetWindowText/GetForegroundWindow Pin
pat27088124-Aug-04 5:46
pat27088124-Aug-04 5:46 
GeneralRe: GetWindowText/GetForegroundWindow Pin
Charlie Williams24-Aug-04 6:18
Charlie Williams24-Aug-04 6:18 
GeneralRe: GetWindowText/GetForegroundWindow Pin
pat27088124-Aug-04 7:02
pat27088124-Aug-04 7:02 
GeneralRe: GetWindowText/GetForegroundWindow Pin
pat27088124-Aug-04 11:44
pat27088124-Aug-04 11:44 
GeneralCopying txt input from 1 form to the other Pin
steve_rm24-Aug-04 5:14
steve_rm24-Aug-04 5:14 
GeneralRe: Copying txt input from 1 form to the other Pin
Steve Maier24-Aug-04 5:26
professionalSteve Maier24-Aug-04 5:26 
GeneralRe: Copying txt input from 1 form to the other Pin
Heath Stewart24-Aug-04 8:57
protectorHeath Stewart24-Aug-04 8:57 
This is object-oriented development. You need to ensure that objects can access easy other. In this case, make sure that one form can access another, either by passing a variable to a method (perhaps the constructor), assigning a property, or have some intermediary that can access both form objects.

Now, Steve was talking about encapsulation and that is a good idea. Exposing the actual TextBoxes to outside code is not (almost never is) a good idea. Remember that those TextBoxes have a lot more properties that could be abused.

So, you could simply encapsulate the Text property on your form class (remember that the property would be defined on your form class and not Form, so you may have to cast to your type depending on how one form accesses another):
public string StudentID
{
  get { return txtStudentID.Text; }
  set { txtStudentID.Text = value; }
}
If you don't want this publicly accessible and the forms are not derivative of each other, you can use the internal access modifier, which means that any code within that particular assembly (.NET 2.0 defines an attribute that grants other assemblies that you specify access to internals as well) can access that property (like public only for that assembly, but private to other assemblies).

 

Software Design Engineer
Developer Division Sustained Engineering, Microsoft
My Articles
GeneralRe: Copying txt input from 1 form to the other Pin
steve_rm25-Aug-04 3:02
steve_rm25-Aug-04 3:02 
GeneralRe: Copying txt input from 1 form to the other Pin
LongRange.Shooter25-Aug-04 4:44
LongRange.Shooter25-Aug-04 4:44 
Generalproject options (advice) Pin
HudsonKane24-Aug-04 3:13
HudsonKane24-Aug-04 3:13 
GeneralRe: project options (advice) Pin
Steve Maier24-Aug-04 4:45
professionalSteve Maier24-Aug-04 4:45 
GeneralRe: project options (advice) Pin
HudsonKane24-Aug-04 5:33
HudsonKane24-Aug-04 5:33 
GeneralRe: project options (advice) Pin
HudsonKane24-Aug-04 5:36
HudsonKane24-Aug-04 5:36 
GeneralRe: project options (advice) Pin
Steve Maier24-Aug-04 7:13
professionalSteve Maier24-Aug-04 7:13 
GeneralRe: project options (advice) Pin
HudsonKane24-Aug-04 8:19
HudsonKane24-Aug-04 8:19 
GeneralWeb application config Pin
jzb24-Aug-04 3:09
jzb24-Aug-04 3:09 
GeneralRe: Web application config Pin
Steven Campbell24-Aug-04 3:51
Steven Campbell24-Aug-04 3:51 
QuestionHow can I pass byte array from C++ to c# ? Pin
neoksd24-Aug-04 2:31
neoksd24-Aug-04 2:31 
AnswerRe: How can I pass byte array from C++ to c# ? Pin
billb211224-Aug-04 3:31
billb211224-Aug-04 3:31 
GeneralRe: How can I pass byte array from C++ to c# ? Pin
neoksd24-Aug-04 4:16
neoksd24-Aug-04 4:16 
GeneralRe: How can I pass byte array from C++ to c# ? Pin
billb211224-Aug-04 5:45
billb211224-Aug-04 5:45 
AnswerRe: How can I pass byte array from C++ to c# ? Pin
Heath Stewart24-Aug-04 8:03
protectorHeath Stewart24-Aug-04 8:03 
GeneralRe: How can I pass byte array from C++ to c# ? Pin
neoksd26-Aug-04 15:23
neoksd26-Aug-04 15:23 
GeneralRe: Declaration Default Argument Values Pin
S Sansanwal23-Aug-04 23:54
S Sansanwal23-Aug-04 23:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.