mphillip85
asked on
create a class that will lopad values to a combobox or a datagrid
C# 2005 Professional
earning how to write classes
I want to write a class like i would do with a function in VB.net to load values to object that I place on my form
thank you
earning how to write classes
I want to write a class like i would do with a function in VB.net to load values to object that I place on my form
thank you
ASKER
I just want to populate the properties of the combobox1 for example.
this is what the class would have in it.
with combobox1
.comboname = "combobox1"
.datasource = "dataset1"
.displaymember = "columnname"
.valuemember = "columnname"
end with
then in the main form i want to do this
namespace.program.loadcomb o(string comboname, string dsource, string dmember, string vmember);
when I make this call in the main form load section it will pull the data from the database that I want.
then i can use the same code and modify it to use for the datagrid and filter off of the combobox selected value to trigger the rows to retrieve for the datagrid.
thank you
this is what the class would have in it.
with combobox1
.comboname = "combobox1"
.datasource = "dataset1"
.displaymember = "columnname"
.valuemember = "columnname"
end with
then in the main form i want to do this
namespace.program.loadcomb
when I make this call in the main form load section it will pull the data from the database that I want.
then i can use the same code and modify it to use for the datagrid and filter off of the combobox selected value to trigger the rows to retrieve for the datagrid.
thank you
ASKER
I would like to learn how to do this in a class rather than a function.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
in the first example i get this.
Error 1 Type expected 7 32 WindowsApplication2
Error 2 Identifier expected, 'string' is a keyword 7 55 WindowsApplication2
Error 3 Identifier expected, 'object' is a keyword 7 75 WindowsApplication2
Error 4 Identifier expected, 'string' is a keyword 7 94 WindowsApplication2
Error 5 Identifier expected, 'string' is a keyword 7 118 WindowsApplication2
Error 6 ; expected 7 141 WindowsApplication2
Error 7 Invalid token '=' in class, struct, or interface member declaration 9 17 WindowsApplication2
Error 8 Invalid token ';' in class, struct, or interface member declaration 9 30 WindowsApplication2
Error 9 Invalid token '=' in class, struct, or interface member declaration 10 23 WindowsApplication2
Error 10 Invalid token ';' in class, struct, or interface member declaration 35 WindowsApplication2
Error 11 Class, struct, or interface method must have a return type 11 9 WindowsApplication2
Error 12 Identifier expected 11 33 WindowsApplication2
Error 13 ; expected 11 34 WindowsApplication2
Error 14 Invalid token '=' in class, struct, or interface member declaration 27 WindowsApplication2
Error 15 Invalid token ';' in class, struct, or interface member declaration 12 39 WindowsApplication2
Error 16 Invalid token '.' in class, struct, or interface member declaration 13 15 WindowsApplication2
Error 17 Class, struct, or interface method must have a return type 13 16 WindowsApplication2
Error 18 Identifier expected 13 41 WindowsApplication2
Error 19 ; expected 13 42 WindowsApplication2
Error 20 Invalid token '=' in class, struct, or interface member declaration 14 25 WindowsApplication2
Error 21 Invalid token ';' in class, struct, or interface member declaration 14 38 WindowsApplication2
Error 22 Expected class, delegate, enum, interface, or struct 17 17 WindowsApplication2
Error 23 Type or namespace definition, or end-of-file expected 25 1 WindowsApplication2
Error 1 Type expected 7 32 WindowsApplication2
Error 2 Identifier expected, 'string' is a keyword 7 55 WindowsApplication2
Error 3 Identifier expected, 'object' is a keyword 7 75 WindowsApplication2
Error 4 Identifier expected, 'string' is a keyword 7 94 WindowsApplication2
Error 5 Identifier expected, 'string' is a keyword 7 118 WindowsApplication2
Error 6 ; expected 7 141 WindowsApplication2
Error 7 Invalid token '=' in class, struct, or interface member declaration 9 17 WindowsApplication2
Error 8 Invalid token ';' in class, struct, or interface member declaration 9 30 WindowsApplication2
Error 9 Invalid token '=' in class, struct, or interface member declaration 10 23 WindowsApplication2
Error 10 Invalid token ';' in class, struct, or interface member declaration 35 WindowsApplication2
Error 11 Class, struct, or interface method must have a return type 11 9 WindowsApplication2
Error 12 Identifier expected 11 33 WindowsApplication2
Error 13 ; expected 11 34 WindowsApplication2
Error 14 Invalid token '=' in class, struct, or interface member declaration 27 WindowsApplication2
Error 15 Invalid token ';' in class, struct, or interface member declaration 12 39 WindowsApplication2
Error 16 Invalid token '.' in class, struct, or interface member declaration 13 15 WindowsApplication2
Error 17 Class, struct, or interface method must have a return type 13 16 WindowsApplication2
Error 18 Identifier expected 13 41 WindowsApplication2
Error 19 ; expected 13 42 WindowsApplication2
Error 20 Invalid token '=' in class, struct, or interface member declaration 14 25 WindowsApplication2
Error 21 Invalid token ';' in class, struct, or interface member declaration 14 38 WindowsApplication2
Error 22 Expected class, delegate, enum, interface, or struct 17 17 WindowsApplication2
Error 23 Type or namespace definition, or end-of-file expected 25 1 WindowsApplication2
Please provide the code that you are using. Please be sure to include the desinger file code as well.
-saige-
-saige-
ASKER
CSharpExample.Extensions.C onfigure(c omboBox1, "comboBox1" , dataSet1, "dbobject.dbtable", "dbobject.dbtable");
dbobjectTableAdapter.Fill( this.dataS et1.dbobje ct);
I have it working now.
going to try the datagrid now
thank you
dbobjectTableAdapter.Fill(
I have it working now.
going to try the datagrid now
thank you
ASKER
I felt good about the code that was shown, which i just needed to adjust to my environment and it worked fine. I am thankful for having to have it work 90% so i could learn the 10% that was needed to make it work in my solution.
Great!
Great!
For Example:
Open in new window
Now you could create a new List of people and put them into a datagrid or combobox (dont forget to add them to the form):
Open in new window
The above produces the following output:
-saige-