Updating a field from a combo box lookup

  • Thread starter Thread starter Vinnie the Rat
  • Start date Start date
V

Vinnie the Rat

I need to provide a pick list for a data entry field. I do everything but
take the selected value and get it into the dataset for eventual update to
the the database. I can show the field of the dataset and I have a separate
combo box field but can't seem to connect the two. Maybe I'm going about
this in the wrong way but any help will be greatly appreciated.
 
I need to provide a pick list for a data entry field. I do everything but
take the selected value and get it into the dataset for eventual update to
the the database. I can show the field of the dataset and I have a separate
combo box field but can't seem to connect the two. Maybe I'm going about
this in the wrong way but any help will be greatly appreciated.

Sorry - I genuinely tried to understand your question, but can't
follow;
Please try to be less succinct - i.e. give us some more information
about what you are trying to do, maybe with a small code example if
appropriate?
 
Sorry for the vagueness and appreciate the interest. Looking at it from the
user's view, the Windows application would show a field from the database,
say "color". Next to that field would be a combo box, and in the dropdown
list would be all the colors to choose from. The user would click on, say,
"blue" and then "blue" would show up in the aforementioned field. That
field's source would be from a dataset, drawn from a database. I want to
update the database with the selected color, in this case "blue". Behind
the scenes, how would I reference the dataset "color" in order to get the
value that is selected in the combo box over to that field? Not sure if
this is the right order, maybe I reference the field to be updated from a
combo box property or method but I need to have the user select something
from the combo box that will update the data field in the database. Hope
I'm not being to simple here, at the expense of clarity. Again, thanks for
anything you might tell me.
 
Hi Vinnie,

I am just learning C# using VS 2008 Express, and am building a small
database project to "get my hands dirty", so my advice may not be the
best considering my experience!

One way to solve your problem: (I did something similar in my own
program, and it works perfectly)
1: table UserTable with a column "color" (the field you wish to change)
2: table ColorsTable with records of all interesting colors, column is
"aColor"

Define column "color" in UserTable as DataGridViewComboBoxColumn

create a foreign key relation between UserTable and ColorsTable : from
"color" to "aColor"
add a relation between UserData table column "color" and ColorsTable
column "aColor" (in the dataset designer)

When you view the table UserTable in a datagrid or individual controls,
the combobox "color" should be filled with all available colors from
table ColorsTable.

The above is one way to avoid having a separate combobox to select
color.
Less clutter and easier on the user...

Hope I have provided a correct possible solution!

regards

//pc-one
 
Edited the procedure below...

//pc-one

//pc-one said:
Hi Vinnie,

I am just learning C# using VS 2008 Express, and am building a small
database project to "get my hands dirty", so my advice may not be the
best considering my experience!

One way to solve your problem: (I did something similar in my own
program, and it works perfectly)
1: table UserTable with a column "color" (the field you wish to
change)
2: table ColorsTable with records of all interesting colors, column is
"aColor"

Define column "color" in UserTable as DataGridViewComboBoxColumn

******************* Edited section
add a foreign key relation between UserTable and ColorsTable : from
"color" to "aColor" (in the dataset designer) ******************

When you view the table UserTable in a datagrid or individual
controls, the combobox "color" should be filled with all available
colors from table ColorsTable.

The above is one way to avoid having a separate combobox to select
color.
Less clutter and easier on the user...

Hope I have provided a correct possible solution!

regards

//pc-one


news:[email protected]...
<snipped>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top