DatagridView ComboBox cell set ups

swap123

Member
Joined
Aug 11, 2009
Messages
6
Programming Experience
1-3
Hi,

I have a question regarding setting up the DataGridViewCell as DataGridViewComboBox cell.

I am changing the properties of the column through the Property Window

1. I have a datagridview connected to an Employee Trades Table through EmployeeTradesBindingSource

2. One of the columns in the gridview called "Comments" (which is a field in employee trades table) I want to populate from another table "Trade Comments" through 'EmployeeTradesBindingSource'

3. So I edited the column Property set the
.DataSource = EmployeeTradesBindingSource
.DataPropertyName = Comment( column name in "Trade Comments")
.DisplayMember = "Comments"
.DisplayStyle = DropDownButton

Now when the grid is displayed, I am getting the 'Comments' as a combo box but there is no value in the current cell of the grid, but I have to select it from the combo. When the grid is displayed my current cell is blank for Comments.

What will I do to display that?

Also when I change the comment to another comment and click save, employeetradesBindingsource will update the 'Employee Trades' Table except for the 'Comments' column

I feel my Comments column is behaving independent of EmployeeTrades table and only depending on TradeComments Table

What will I do to resolve this?

If I get any help asap, I would highly appreciate it

Thanks in advance!!!
 
Confusing. Pick a scenario:

You have 2 tables
One table has a "Comments" field but this field can only contain at most ONE comment that is a fixed text found in another table
Hence the main table has a "Comment ID" style coolumn, and then the correct comment is looked up from another table

or

You have 2 tables
One table has a Comments field (for some unknown reason)
The other table has multiple free text comments all filed under one ID number (the ID number of a particular row in EmployeeTrades)
You want to show the trade as a single row, and have some way of representing all the comments about that particular trade

-
you cannot do option 2 with a dtagridviewcombobox; that is not its function. DGVCB is intended to maintain a decode list from ID<-->Friendly Value, and show the user the Friendly Value (e.g. Mr, Mrs, Miss) while updating the main table with the ID (e.g. 1, 2, 3)

For option 2 you would use another bindingsource, another grid (or list) and when the .Position of the main BS changed you'd fill the related comments in, or you would use a datarelation, and fill all the comments (if youre downloading 10 trades, also download all related 60 comments and let the relation filter)
 
Back
Top