Click here to Skip to main content
16,005,473 members
Home / Discussions / C#
   

C#

 
GeneralRe: #define Pin
mebmer 12345678914-Sep-04 21:50
mebmer 12345678914-Sep-04 21:50 
GeneralHANDLE Pin
eggie514-Sep-04 14:39
eggie514-Sep-04 14:39 
GeneralRe: HANDLE Pin
Colin Angus Mackay14-Sep-04 14:56
Colin Angus Mackay14-Sep-04 14:56 
QuestionHow to change the text of a text object at runtime in crystal reports for .NET (C#) Pin
Member 119488414-Sep-04 11:45
Member 119488414-Sep-04 11:45 
AnswerRe: How to change the text of a text object at runtime in crystal reports for .NET (C#) Pin
sreejith ss nair14-Sep-04 18:42
sreejith ss nair14-Sep-04 18:42 
AnswerRe: How to change the text of a text object at runtime in crystal reports for .NET (C#) Pin
Member 119488414-Sep-04 20:08
Member 119488414-Sep-04 20:08 
Generalaccessing listbox items on a form from another class Pin
mr spoon14-Sep-04 10:20
mr spoon14-Sep-04 10:20 
GeneralRe: accessing listbox items on a form from another class Pin
Heath Stewart14-Sep-04 11:45
protectorHeath Stewart14-Sep-04 11:45 
Your objects must be referenced and must be accessible. In order to access a member of one object, you must have a reference to that object. In this case, that object is your Form derivative. In order for your second Form to reference the first, you must either pass it a reference (in the constructor or set a property or call a method), or it may have one already depending on how the second Form was opened. If it was opened from the first Form using ShowDialog(this), then the second's Form.Owner should reference that first Form, though you'll need to cast it to your form type ((CODLauncher)this.Owner) in order to access the field defined by CODLauncher (it's not defined on Form).

Second, your fields lbMapList and lbMapRotation must be accessible. By default, the Visual Studio .NET (VS.NET) designer adds controls as private, meaning only that class can access the fields (that reference your controls). With a control selected, you can right-click and select "Properties", then change the Access property to something like "public" (though exposing controls directly like this isn't a good idea; you should expose the necessary properties like I've done below).

You should read Access Modifiers[^] in the Visual C# language reference for more information about access modifiers.

Here's an example of what I explained above:
using System;
using System.Drawing;
using System.Windows.Forms;
 
class Parent : Form
{
  private TextBox txt;
  private Button btn;
 
  static void Main()
  {
    Application.Run(new Parent());
  }
 
  public Parent()
  {
    this.Text = "Example: Parent Form";
 
    this.txt = new TextBox();
    this.txt.Location = new Point(8, 8);
 
    this.btn = new Button();
    this.btn.Location = new Point(8, this.txt.Bottom + 8);
    this.btn.Text = "Show Child";
    this.btn.Click += new EventHandler(this.btn_Click);
 
    this.Controls.Add(this.txt);
    this.Controls.Add(this.btn);
  }
 
  private void btn_Click(object sender, EventArgs e)
  {
    using (Child form = new Child()) // Make sure 'form' gets disposed
      form.ShowDialog(this);
  }
 
  public string ImportantText
  {
    get { return this.txt.Text; } // Do not expose 'txt' directly.
  }
}
 
class Child : Form
{
  private Label lbl;
 
  public Child()
  {
    this.Text = "Example: Child Form";
 
    this.lbl = new Label();
    this.lbl.Location = new Point(8, 8);
 
    this.Controls.Add(this.lbl);
  }
 
  // Owner is not available during construction.
  protected override void OnLoad(EventArgs e)
  {
    this.lbl.Text = ((Parent)this.Owner).ImportantText;
  }
}


This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles]
GeneralRe: accessing listbox items on a form from another class Pin
mr spoon15-Sep-04 10:23
mr spoon15-Sep-04 10:23 
GeneralStored Procedures with C# Pin
Member 131560014-Sep-04 9:47
Member 131560014-Sep-04 9:47 
GeneralRe: Stored Procedures with C# Pin
Steve Maier14-Sep-04 10:42
professionalSteve Maier14-Sep-04 10:42 
GeneralRe: Stored Procedures with C# Pin
Heath Stewart14-Sep-04 11:20
protectorHeath Stewart14-Sep-04 11:20 
GeneralRe: Stored Procedures with C# Pin
Steve Maier14-Sep-04 15:25
professionalSteve Maier14-Sep-04 15:25 
GeneralRe: Stored Procedures with C# Pin
Heath Stewart14-Sep-04 11:29
protectorHeath Stewart14-Sep-04 11:29 
GeneralDatgrid Record Count Pin
thewilddba14-Sep-04 9:25
thewilddba14-Sep-04 9:25 
GeneralRe: Datgrid Record Count Pin
Angel Reyes14-Sep-04 9:44
Angel Reyes14-Sep-04 9:44 
GeneralRe: Datgrid Record Count Pin
sreejith ss nair14-Sep-04 18:09
sreejith ss nair14-Sep-04 18:09 
Generalscroll bar i the listview control Pin
bora3ee14-Sep-04 8:36
bora3ee14-Sep-04 8:36 
GeneralRe: scroll bar i the listview control Pin
Dave Kreskowiak14-Sep-04 9:51
mveDave Kreskowiak14-Sep-04 9:51 
Generalzip libraries Pin
elena1234514-Sep-04 8:14
elena1234514-Sep-04 8:14 
GeneralRe: zip libraries Pin
Gary Thom14-Sep-04 10:07
Gary Thom14-Sep-04 10:07 
GeneralRe: zip libraries Pin
Steve Maier14-Sep-04 10:44
professionalSteve Maier14-Sep-04 10:44 
GeneralRe: zip libraries Pin
Heath Stewart14-Sep-04 11:17
protectorHeath Stewart14-Sep-04 11:17 
GeneralRe: zip libraries Pin
suthan14-Sep-04 19:50
suthan14-Sep-04 19:50 
GeneralRe: zip libraries Pin
leppie15-Sep-04 6:07
leppie15-Sep-04 6:07 

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.