hi everyone!!! need help here, how can i pass a string to a class? i have two forms and a class, my 1st form is the main form and the other form is used for assigning to a keyer, this form has a combobox where i will select the keyer i want, after selecting the keyer i will now pass the keyer id/name to my class, this is where im having trouble. help me here please.. thank you...

Recommended Answers

All 3 Replies

You can use class properties to do this. A simple example:

public class MyClass
{
  public string MyProperty
  {
    get;
    set;
  }
}
public partial class MyForm: Form
{
  private MyClass myObject;

  public MyForm()
  {
    InitializeComponents();
    myObject = new MyClass();
  }
  
  public void PassString(string str)
  {
    myObject.MyProperty = str;
  }
}

hi everyone!!! need help here, how can i pass a string to a class? i have two forms and a class, my 1st form is the main form and the other form is used for assigning to a keyer, this form has a combobox where i will select the keyer i want, after selecting the keyer i will now pass the keyer id/name to my class, this is where im having trouble. help me here please.. thank you...

U can use properties of the class

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.