Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > DataGridView Combobox set datasource for each record
 

DataGridView Combobox set datasource for each record

hi everybody,
i have a dataentry form to store address of some customers .

The City was in a combobox column and post code was also in another on combobox column .
Is it possiple to filter te postcode depending upon the city selected on particular record.

i try to filter the datsource . but it populates some error

DataGridViewComboBoxCell value is not valid.

thanks in advance

annamalai
askitanna  Tuesday, July 28, 2009 7:27 AM
Yes, when doing things like this you will get that error.

The best thing to do is follow the instructions on that error. I believe that the error tells you to add an event handler for the DataGridView DataError event?

Hope this helps.
www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
DeborahK  Tuesday, July 28, 2009 4:36 PM
Yes, when doing things like this you will get that error.

The best thing to do is follow the instructions on that error. I believe that the error tells you to add an event handler for the DataGridView DataError event?

Hope this helps.
www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
DeborahK  Tuesday, July 28, 2009 4:36 PM

Hi askitanna,

From my experience, it is possible to filter the data source of one DataGridViewComboxColumn upon the selected value of a cell in another DataGridViewComboxColumn. But we need to check the selected value in another column before we filter the data source. If the value is illegal, we would meet an error the same to yours. You can follow DeborahK’s advice to handle the DataError event of the DataGridView to check the root cause of the error and then cope with the illegal value before filtering the data source. You can ignore the illegal value or show some errors to the user.

Let me know if this helps.
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Wednesday, July 29, 2009 7:02 AM

You can use google to search for other answers

Custom Search

More Threads

• Problem with SQLDependency "Cross-thread operation not valid"
• BindingList.Add behaviour (Extremley slow!)
• How to add rows to a shared datatable residing in another class?
• Losing data when adding first child row
• Check if underlying dataset was updated
• Selecting blocks of cells - determining topleft/bottom right + restricting to contiguous
• Out of memory
• Joining two tables to display data on the dataGrid
• Sorting a dataGrid view while binding custom collection
• problems in adding rows to datagrid