rturney
asked on
Attempting to create class for common mysql methods but can't create method that returns a combo box
I am learning C# and am struggling with classes. I have a C# program that uses MySQL methods residing in Form1. Another form, Form2, must share these methods. I added a new class, MyClass, to hold these common methods. I declare them as:
public static string method1() // because all the methods return a string value.
My problem is that in a few cases I have a method that needs to return a ComboBox or a ListBox. I already did this when the method was in Form1, but when I tried to move it to MyClass and set it up as:
public static ComboBox method2()
the ComboBox is not available as a possible return type in the pulldown list (as you type). Neither is ListBox or ArrayList. Array is available but I'm not sure how to use it. The ComboBox and ListBox return types were very convenient to return a list. I could use ArrayList. I haven't tried a string array because of the difficulty in declaring its size before knowing how many items will be returned.
The method is supposed to return a list of items that satisfy the given MySQL query.
Thanks,
-Bob
public static string method1() // because all the methods return a string value.
My problem is that in a few cases I have a method that needs to return a ComboBox or a ListBox. I already did this when the method was in Form1, but when I tried to move it to MyClass and set it up as:
public static ComboBox method2()
the ComboBox is not available as a possible return type in the pulldown list (as you type). Neither is ListBox or ArrayList. Array is available but I'm not sure how to use it. The ComboBox and ListBox return types were very convenient to return a list. I could use ArrayList. I haven't tried a string array because of the difficulty in declaring its size before knowing how many items will be returned.
The method is supposed to return a list of items that satisfy the given MySQL query.
Thanks,
-Bob
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much for help Fernando! Things seem hard now but help like yours is making the process smoother.
Best regards,
-Bob
Best regards,
-Bob
In answer to your question, Yes.
Your welcome, glad I was of some help. ;=)
Your welcome, glad I was of some help. ;=)
ASKER
Will Form1 and Form2 be able to access the methods in MyClass by using:
comboBox1 = MyClass.method(...);
as long as method(...) is declared in MyClass as
public static ComboBox method(...) ?
-Bob