Getting text from a cell in a datagrid?
I would like to get the text in a specific cell in a datagrid. I know with VB.NET, you can use grid.Item() and it can also be done using a flexgrid in VB6 with no problem. But for speed reasons (a datagrid + ado loads records faster than ado + flexgrid because of the need to populate the grid programmatically), I would like to stick with a datagrid. I'd rather use a flexgrid because I prefer its fuctionality, but when loading 30 columns of data with 10,000+ entries, it bogs the application down a bit. The datagrid populates pretty much instantaneously.
So I have the datagrid and ado recordsource set to "select * from results" And I want to get the text in the grid from column x, curent row (grid.Row)
Sounds easy enough, but I can't find anything about it for VB6.
Thanks for the help.
Re: Getting text from a cell in a datagrid?
Quote:
Originally Posted by sdouble
I would like to get the text in a specific cell in a datagrid. I know with VB.NET, you can use grid.Item() and it can also be done using a flexgrid in VB6 with no problem. But for speed reasons (a datagrid + ado loads records faster than ado + flexgrid because of the need to populate the grid programmatically), I would like to stick with a datagrid. I'd rather use a flexgrid because I prefer its fuctionality, but when loading 30 columns of data with 10,000+ entries, it bogs the application down a bit. The datagrid populates pretty much instantaneously.
So I have the datagrid and ado recordsource set to "select * from results" And I want to get the text in the grid from column x, curent row (grid.Row)
Sounds easy enough, but I can't find anything about it for VB6.
Thanks for the help.
Try this
Code:
grid1.col=x
text1.text=grid1.text
Re: Getting text from a cell in a datagrid?
Quote:
I'd rather use a flexgrid because I prefer its fuctionality, but when loading 30 columns of data with 10,000+ entries, it bogs the application down a bit. The datagrid populates pretty much instantaneously.
Perception is an amazing thing... The DataGrid simply shows the user the rows that are in view, the rest are not populated until they need to be. You could do the same with the FlexGrid. Also when loading the Flexgrid make use of it's Redraw property.
Anyways, to get the text of a specific cell is a bit of a pain.
'to get from the current row
DataGrid1.Columns(1).CellText(DataGrid1.Bookmark)
'Relative from the top most visible row. Note that the row must be visible. DataGrid1.Columns(1).CellText(DataGrid1.Bookmark(RowNum))
'54th row from current row.
DataGrid1.Columns(1).CellText(DataGrid1.GetBookmark(54))
The Column object also has a CellValue method.
CellText = formatted text displayed to user
CellValue = underlying recordset value.
Re: Getting text from a cell in a datagrid?
Quote:
Originally Posted by brucevde
Perception is an amazing thing... The DataGrid simply shows the user the rows that are in view, the rest are not populated until they need to be. You could do the same with the FlexGrid. Also when loading the Flexgrid make use of it's Redraw property.
Ah, quite interesting. I had no idea. I thought it seemed wierd that it was so much faster since the data should be received at the same speed. I tested this out with random numbers instead of a query and it was just as fast as the datagrid. Excellent tip.
The code you mentioned is exactly what I was looking for. Thanks a bunch! :D