I’m using a DataGridView with C#.NET. When a user is editing a column, I need another column in the same grid to change with every keystroke/change. How/where do I insert my own code for this type of event?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What you’re trying to achieve is not possible without a bit of work. By default the
DataGridViewclass does not provide aCellChangingstyle event. Instead it provides book ended events in the form ofCellBeginEditandCellEndEdit.Part of the reason is likely due to the varying ways in which a cell can be editted. Having a
CellChangingwould make sense for a text style cell but wouldn’t make as much sense for say aButtonstyle cell.You could easily implement a solution though which propagated the value once it was completely entered via the above said events.
The only way I can see to implement it for every keystroke would be to
DataGridView.EditingControlis and find a way to hook into every single change for every type of cellEven then I think you still may run into issues because I’m not sure if
DataGridViewis designed to have cell values changed while a different one is being actively edited.