Red X when trying to re-use a grid for another data set??

G

Guest

I have a grid that I use to display 4 or 5 different tables with different number of columns. I read some where that you cannot bind a different data set to a grid once you bind one data set to it. I am programatically filling the datagrid with a dataset that is being built on the fly. I am using VFP databases and codebase as well, so I have found no easier way to do this. At any rate when I finish viewing a database and try to clear out the grid, it seems like I am then getting the big red X. Is there something I am doing incorrectly? Here is a code snippet..

BrowseDataSet.Tables.Clear(
BrowseDataSet.Clear(
BrowseDataSet.Dispose(

BrowseTable.BeginLoadData(
BrowseTable.Clear(

' Destroy the columns in the table - I was doing this to destroy column by column but kept getting problems with
' trying to remove some column

' browsearr is just an array set up where the firs member Browsearr(0) is the number of columns in the tabl
' Members 1, 3, 5, 7 are the names of the columsn, 2,4,6,8, and so on are pointers to the data in my CODEBASE structures

'For ICol = 0 To piNumCols -
' ' Get the type of this fiel
' pcFieldName = BrowseArr(ICol * 2 + 1
' Tr
' BrowseTable.Columns.Remove(BrowseTable.Columns(pcFieldName)
' Catc
' End Tr
'Next ICo

'Do While BrowseTable.Columns.Count >
' Tr
' BrowseTable.Columns.Remove(BrowseTable.Columns(BrowseTable.Columns.Count - 1)
' Catc
' ' Do nothing
' 'BrowseTable.Clear(
' End Tr
'Loo
BrowseTable.EndLoadData(

' i THINK THIS IS WHERE THE BIG RED x COMES FROM.....
Tr
o.grdData.Enabled = Fals
o.grdData.Visible = Fals
Catc
End Tr
 
C

Claes Bergefall

Looks like you're destroying the dataset while the grid is still bound to it
The red x is actually an exception in the paint handlers and there seems to
be some kind of bug in the grid that causes it to appear at certain times
(particulary when scrolling and rebinding). Reseting the databinding worked
for us so try adding this call at the top of your code (i.e before
destroying the dataset or rebinding the grid):
o.grdData.SetBinding(Nothing, Nothing)
(I'm assuming that o.grdData is a DataGrid)

/claes

kmgauvin said:
I have a grid that I use to display 4 or 5 different tables with different
number of columns. I read some where that you cannot bind a different data
set to a grid once you bind one data set to it. I am programatically filling
the datagrid with a dataset that is being built on the fly. I am using VFP
databases and codebase as well, so I have found no easier way to do this. At
any rate when I finish viewing a database and try to clear out the grid, it
seems like I am then getting the big red X. Is there something I am doing
incorrectly? Here is a code snippet...
BrowseDataSet.Tables.Clear()
BrowseDataSet.Clear()
BrowseDataSet.Dispose()

BrowseTable.BeginLoadData()
BrowseTable.Clear()

' Destroy the columns in the table - I was doing this to destroy
column by column but kept getting problems with
' trying to remove some columns

' browsearr is just an array set up where the firs member Browsearr(0)
is the number of columns in the table
' Members 1, 3, 5, 7 are the names of the columsn, 2,4,6,8, and so on
are pointers to the data in my CODEBASE structures.
'For ICol = 0 To piNumCols - 1
' ' Get the type of this field
' pcFieldName = BrowseArr(ICol * 2 + 1)
' Try
' BrowseTable.Columns.Remove(BrowseTable.Columns(pcFieldName))
' Catch
' End Try
'Next ICol

'Do While BrowseTable.Columns.Count > 0
' Try
'
BrowseTable.Columns.Remove(BrowseTable.Columns(BrowseTable.Columns.Count -
1))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top