Data Grid Viewに入力できるコンボボックスを1セルだけ作成する。 入力されたアイテムがコンボボックス内のリストになければ、コンボボックス内のリストの先頭に追加する。 これを実現するために、Data Grid ViewのEditing Control ShowingイベントとCell Validatingイベントでいろいろする必要がある。 Editing Control Showingイベントは、編集用のコンボボックスが作成され表示される直前にコールされる。 Data Grid Viewの場合はData Grid View Combo Box Editing Controlが作成されるが、このコントロールのDrop Down StyleをCombo Box Style.I need to find out the order of events that are fired when a Row is updated in a Data Grid View control. | MSDN Data Walkthroughs VBForums Database Development FAQ My Code Bank Submissions: VB | C# My Blog: Data Among Multiple Forms (3 parts) Beginner Tutorials: VB | C# | SQL Gee thanks..I am having trouble determining when my Data Grid View object is sorting (based on a column header click).
I looked at the Sort Compare event, but it never seemed to be fired at all. Sort() function) Problem 2) When you click the top of a column to sort the data, all the cellstyles disapear.
anyone know how to keep the cellstyling the same between row sorting?
The suggestion of subclassing a Binding List would be way overkill if you want to keep it simple.
[All I was suggesting about Data Table is that when it sorts, the Grid casts the Data Set to IBinding List and calls Apply Sort on it..IF you could override that method, you would be guaranteed to know sorting was happening..you would have to implement your own Binding List to do so...] You are already checking the row, so why not check the column on the Cell Click event as well. Assume you only want Text Box Cell columns sorted (not Button, Check Box, Image or Link).
The Cell Formatting event should really only be used as a last resort for customizations that cannot be cached in a Default Cell Style (and there are several...
Grid, Row, Column, Alternating Row) or its Format string.One more thought..Data Grid View Column has a Sort Mode property...which can be set to Not Sortable for the columns such as all check boxes or whatnot...(assuming you truly do not want them sorted).I guess the Column Header Mouse Click would still be raised, but by setting that Sort Mode there would be no glyph there asking to be clicked.I believe the Sort Compare event is fired only when there is no underlying Binding List, and so the Grid literally compares each cell's text value, which would explain why it is not fired if you have any underlying binding source. That said, there may be an obvious cause of it changing..try to hunt down why...maybe even throw some debug lines into the Cell Style Changed event to see when and how.Although you found a workaround, at a high level it seems to me such a workaround should not be needed...unless you customized the Cell Formatting event on the initial load, but somehow the same Cell Formatting event is not getting called when you sort.You could simple check the Cell Type or Cell Template property of the column before firing the splash screen. Set the Sort Mode of each column (it's a public property, so I would consider that minimal code interference) at initialization, and then at Cell Click get the column and only fire the splash screen for columns that are not Not Sortable. As for the cellformating, I stopped looking into it when I found the cellformating event, lets me supply dynamic cell formating based on cell contents.