15,916,091 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by AcidUser85 (Top 2 by date)
AcidUser85
19-Nov-15 3:01am
View
Hi, I forgot to mention that my solution also does automatic sort of datagridview rows by 2 columns when focus is lost or another control selected. So marking for deletion would mess up things.
It works like this:
DataGridView is in my case of two columns.
1-st column is column of comboboxes (sort of type).
2-nd column is column of textboxes (sort of text description).
A combobox has items, let's say "Custom","AAAA","BBBB","CCCC".
When user selects "Custom", then ComboBox is set to editable and user can type custom value, that will be added to ComboBox items.
I thought about making cell read-only when selected item is "Custom".
But I cannot force user to input correct value for combobox before navigating away. And since DataGridView automatically adds new blank row, it can result in multiple not correctly formatted rows.
AcidUser85
18-Nov-15 12:28pm
View
In my solution I remove rows if combobox seleted value is empty or "custom" in case if user moves to another cell or another row, another control is focused or user clicks outside of datagridview control - on to form.
That's why I cannot use cellvalidating and cellvalidated events - these event's do not allow to remove row. Also I experienced instability when using multiple events, that's why I handle everything in "DirtyStateChanged" event.
I tried assigning "SelectedIndexChanged" to combobox cell editing control, but this never worked for me.