DataGridView sorting with nulls in DateTime column

前端 未结 5 1176
猫巷女王i
猫巷女王i 2021-01-14 04:30

I\'ve got a DataGridView control in a Windows forms application. There are four columns with string data and three with DateTime data. I\'m adding the rows programmatically

5条回答
  •  不知归路
    2021-01-14 04:45

    If you're adding rows dynamically I must assume the DataGridView is not Databound. In this case why don't you check for nulls when populating the correspondent row cells and instantiate some kind of dummy date (some funny date in the past so that it's clear that it was a null - maybe also specify that it's a default value) so that when it comes to sorting it's ll good.

    If this ain't good - what about creating your own DataGridView exactly the same as the built-in one (using inheritance) BUT overriding the sorting method to ignore nulls?

提交回复
热议问题