DataGridView 点击表头排序异常

DataGridView 点击表头排序错误
请问一下
点击Datagridview的表头进行排序
就会提示未将对象引用设置到对象的实例
我在DataGridView1_Click事件里进行了赋值操作
STvalue.teaname = DataGridView1.CurrentRow.Cells("zhut").Value
请问是什么原因
哪位知道告诉一声

------解决方案--------------------
DataGridView1_Click
就是不管点了datagridview控件哪里,都会触发事件!
STvalue.teaname = DataGridView1.CurrentRow.Cells("zhut").Value 
其中的CurrentRow,是获取当前包含该单元格的行(用户选中的行),如果你点了表头排序,当前就没有当前行吧
解决的话,你可以在其它事件里去激发它,如果还有问题,哪看是不是有没有定义了!
------解决方案--------------------
Datagridview有个毛病,一点表头排序,就会刷新Datagridview里的数据,数据刷新了,肯定有哪个值就没了,就会出错,建议把Datagridview的表头排序给封上。
------解决方案--------------------
二楼说的对,我也遇到过,顶
------解决方案--------------------
有分页好像就不能排序吧!
------解决方案--------------------
'你可以在前面加这样一句,默认选中第一行

If DataGridView1.Rows.Count > 0 Then
DataGridView1.CurrentCell = DataGridView1.Rows(0).Cells(1)
End If