TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Michael Jones
NA
2
0
Binding to a DataGridView's DataGridViewComboBoxColumn
Aug 7 2008 2:28 PM
I am using .NET 2.0
I have problem that I am hoping someone here can help me with. It involves using the DataGridViewComboBoxCell in a different way than what was intended by its designers.
I am binding the DataGridView control to a table in a dataset. I set the DataGridViewColumn's DataMember property to a column of my DataTable. One column of my DataGridView is of type DataGridViewComboBoxColumn. I set the DataGridViewComboBoxColumn.DataSource to something like {"one", "two", "three"}
The DataTable column I bind to the DataGridViewComboBoxColumn will have valid values in it so that they match one of the options "one", "two", or "three". Sometimes they might have something like "foo" in them, that do not match one of the options. I subscribe to the DataGridView's DataError event so to handle the error.The default behavior for the DataGridViewComboBoxCell is to select the first option in the list when there was an error. I want a different behavior.
The desired behavior would be to show the invalid value in the cell and change the background color of the cell to red and effectively have the DataGridViewComboBoxColumn selected index = -1;
Anyone have an idea how to implement this?
Reply
Answers (
0
)
Form load slow if add background Image
Position of custom controls messed up by scrollbar?