dating a goth girl - Invoke datagridview cellvalidating

On checkbox columns that all have the same value (or possibly columns that are "unsortable"?

) The Cell Click event is triggered, but the Sorted event is not triggered.

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?

Apply Sort(Property Descri ptor[which is the column name], Sort Direction [the sort glyph]); Only once inside that method can you really be guaranteed the Grid is actually sorting.

Unfortunately, as mentioned, it is a protected method, so you would have to have an entire Binding List implementation to get into that method and possibly raise a custom event or such. By default it should not change just because you have sorted.

In which case, you could check for sorting from your Binding List/Data Source instead of the Grid View...

- But assuming you are binding to a Data View (the underlying IBinding List of the Data Set) then what happens is on the left-click of the column header cell, if sorting is enabled, the Grid calls (IBinding List)Default View.

I had hoped to keep this genereic and as free from preprocessing as possible I did not notice you were checking the Row Index during the cell click, so you are already filtering on the Column Header row, making my suggestion about Column Header Mouse Click irrelevant...sorry.

I think you could do this with a minimum of 'extra' code.

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.

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).

Tags: , ,