Apologies if this has come up before, but I can't find it if it has. I
am fairly new to .Net and am having problems with ghosts in the
datagrid.
Basically I have a find screen that accepts search criteria, then
interrogates a database to find all matching records. These are put
into a dataset, which has a dataview that is used as the datasource of
my datagrid, which is read only. The idea is that the user selects
which record they want to view.
The good news is this all works - well apart from the ghost that is.
Say I run a search that returns 10 records. These all show correctly
in the grid. Say I click on row 9 to highlight it, then go and run a
different search which returns just 5 records. They all display
correctly in the datagrid, then there is a gap and then the previously
highlighted cell remains, just hanging all by itself. It disappears
when you select a real cell, but I can't find any way of getting rid of
this 'ghost' programmaticall y. Any ideas?
If it helps, this is the code I use to populate the datagrid...
Dim conDatabase As New SqlClient.SqlCo nnection
Dim commSQL As New SqlClient.SqlCo mmand
Dim daSQL As New SqlClient.SqlDa taAdapter
Dim dsData As New DataSet
conDatabase.Con nectionString = strConnectionSt ring
conDatabase.Ope n()
commSQL.Connect ion = conDatabase
commSQL.Command Type = CommandType.Sto redProcedure
commSQL.Command Text = "usp_SearchBook s"
' Set parameters
If Me.optTitleAll. Checked = False Then
commSQL.Paramet ers.Add("@Title ", "%" &
Me.txtTitle.Tex t.Trim & "%")
End If
If Me.optSeriesAll .Checked = False Then
Dim clsComboClass As New ComboClass("", 0)
clsComboClass =
CType(Me.cboSer ies.Items(Me.cb oSeries.Selecte dIndex), ComboClass)
commSQL.Paramet ers.Add("@Serie sID", clsComboClass.K eyValue)
End If
If Me.optAuthorAll .Checked = False Then
commSQL.Paramet ers.Add("@Autho r", "%" &
Me.txtAuthor.Te xt.Trim & "%")
End If
' run search
daSQL.SelectCom mand = commSQL
daSQL.Fill(dsDa ta, "Table")
' Show match list in datagrid.
Dim dvView As New DataView(dsData .Tables(0))
dvView.RowState Filter = DataViewRowStat e.OriginalRows
dvView.AllowNew = False
Me.dgResults.Da taSource = dvView
conDatabase.Clo se()
Any help is greatly appreciated.
Cheers
Dave
am fairly new to .Net and am having problems with ghosts in the
datagrid.
Basically I have a find screen that accepts search criteria, then
interrogates a database to find all matching records. These are put
into a dataset, which has a dataview that is used as the datasource of
my datagrid, which is read only. The idea is that the user selects
which record they want to view.
The good news is this all works - well apart from the ghost that is.
Say I run a search that returns 10 records. These all show correctly
in the grid. Say I click on row 9 to highlight it, then go and run a
different search which returns just 5 records. They all display
correctly in the datagrid, then there is a gap and then the previously
highlighted cell remains, just hanging all by itself. It disappears
when you select a real cell, but I can't find any way of getting rid of
this 'ghost' programmaticall y. Any ideas?
If it helps, this is the code I use to populate the datagrid...
Dim conDatabase As New SqlClient.SqlCo nnection
Dim commSQL As New SqlClient.SqlCo mmand
Dim daSQL As New SqlClient.SqlDa taAdapter
Dim dsData As New DataSet
conDatabase.Con nectionString = strConnectionSt ring
conDatabase.Ope n()
commSQL.Connect ion = conDatabase
commSQL.Command Type = CommandType.Sto redProcedure
commSQL.Command Text = "usp_SearchBook s"
' Set parameters
If Me.optTitleAll. Checked = False Then
commSQL.Paramet ers.Add("@Title ", "%" &
Me.txtTitle.Tex t.Trim & "%")
End If
If Me.optSeriesAll .Checked = False Then
Dim clsComboClass As New ComboClass("", 0)
clsComboClass =
CType(Me.cboSer ies.Items(Me.cb oSeries.Selecte dIndex), ComboClass)
commSQL.Paramet ers.Add("@Serie sID", clsComboClass.K eyValue)
End If
If Me.optAuthorAll .Checked = False Then
commSQL.Paramet ers.Add("@Autho r", "%" &
Me.txtAuthor.Te xt.Trim & "%")
End If
' run search
daSQL.SelectCom mand = commSQL
daSQL.Fill(dsDa ta, "Table")
' Show match list in datagrid.
Dim dvView As New DataView(dsData .Tables(0))
dvView.RowState Filter = DataViewRowStat e.OriginalRows
dvView.AllowNew = False
Me.dgResults.Da taSource = dvView
conDatabase.Clo se()
Any help is greatly appreciated.
Cheers
Dave
Comment