我正在使用VB.Net 2010。
我正在尝试使用工具栏按钮来填充我的datagridview
所有记录,包括已删除的记录。我在SQL中使用一个标志列将一行设置为已删除的行,而不是实际删除它,当我再次单击它时,我希望datagridview用未删除的行填充。
以下是我的问题:
每次点击它时,如何更改我按钮的图片以向用户显示哪个视图 - 所有行或只是未删除的行 - 他或她正在查看?或者还有什么方法可以向用户显示此更改吗?
答案 0 :(得分:0)
此示例可能会让您了解处理问题
在按钮的点击事件中编写代码。
Dim GetNonDeletedDataTable As DataTable = GetNonDeletedDataTable()
Dim GetFullDataTable As DataTable = GetFullDataTable()
'
' Fill in the data grid When Imange shows ShowFullRecImg.bmp.
if(GetNonDeletedDataTable.Rows.Count<>0 And this.toolStripButton1.Image = Bitmap.FromFile("c:\\ShowFullRecImg.bmp"))
DataGridView1.DataSource = GetFullDataTable()
this.toolStripButton1.Image = Bitmap.FromFile("c:\\ShowNonDeletedRecImg.bmp")
End if
'
' Fill in the data grid When Imange shows ShowNonDeletedRecImg.bmp.
if(GetFullDataTable.Rows.Count<>0 And this.toolStripButton1.Image = Bitmap.FromFile("c:\\ShowNonDeletedRecImg.bmp"))
DataGridView1.DataSource = GetFullDataTable()
this.toolStripButton1.Image = Bitmap.FromFile("c:\\ShowFullRecImg.bmp")
End if
第一个功能为GetFullDataTable()
Private Function GetFullDataTable() As DataTable
'
' This Function needs to build the data table which contains both deleted and non deleted rows.
Return New DataTable()
End Function
第二个功能为GetNonDeletedDataTable()
Private Function GetNonDeletedDataTable() As DataTable
'
' This Function needs to build the data table which contains non deleted rows.
Return New DataTable()
End Function