|
-
Apr 26th, 2009, 11:47 AM
#1
Thread Starter
Lively Member
How to get the current ROW in datagrid in vb6
Hi,
The ROW property of datagrid gives the current row.But if i try to get a row
which does not fit in the window size(means let say 12 rows fit in my window and i have 20 rows in total) and i scroll to say 15th row and try to get in code
introw=datagrid1.row
It returns 12th row. Any row after 12th row ,it returns 12.
How i can get any of the rows from my datagrid.
Ayyaz
-
Mar 3rd, 2024, 09:58 AM
#2
Re: How to get the current ROW in datagrid in vb6
-
Mar 3rd, 2024, 01:55 PM
#3
Re: How to get the current ROW in datagrid in vb6
@x...not sure why the OP wanted to do this in the first place in 2009 (almost 15 years ago), but seeing as how YOU asked today, I would make a suggestion to YOU (OP's last post was 11 years ago).
If you are using as ADODC Control, In your database table simply add a column (field) numbering 0 to the total number of records.
If you are using SQL, sort on that new field, low to high (again, the field should be 0 to total number of records).
Then, if you click on a ow after scrolling, you can simply do something like this:
Code:
Private Sub DataGrid1_Click() DataGrid1.Col = 1 'where 1 is the column in which the sequential numbers are found (this will depend on where that field is in the database table)
Debug.Print DataGrid1.Text 'this will display the 'row number' in the database.
End Sub
Where the column in the grid contains those numbers is 1 (in the code ex above).
BUT, if you want to do an SQL and sort by some other field, all bets are off.
I really see no need to do this in the first place. It is a DATAgrid, not a FlexGrid....query the table to get whatever you want.
Personally, I NEVER use a dataGrid; found the flexGrids much easier to use anyway.
So, if you so ayy running around anyway, go ahead and tell them their long ago post has been resurrected...they'll be happy!
Sam I am (as well as Confused at times).
-
Mar 4th, 2024, 01:56 AM
#4
Re: How to get the current ROW in datagrid in vb6
Wouldn't be surprised if the Row-Property returns the current VISIBLE row of the Grid.
Use SelectedCell (?), and be done with it....
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Mar 4th, 2024, 08:19 AM
#5
Re: How to get the current ROW in datagrid in vb6
@ It does.
But no option for 'selectedCell', there is a .Text, but its flaky (IMO).
Sam I am (as well as Confused at times).
-
Mar 4th, 2024, 09:56 AM
#6
Re: How to get the current ROW in datagrid in vb6
 Originally Posted by SamOscarBrown
@ It does.
But no option for 'selectedCell', there is a .Text, but its flaky (IMO).
Hmmm.... on SO i found a Reference to .Col and .Row Properties indicating the selected Cell
https://stackoverflow.com/questions/...-vb6-data-grid
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Mar 4th, 2024, 02:55 PM
#7
Re: How to get the current ROW in datagrid in vb6
Yes, but that is by code, I’d assume. When an item is selected that one has to scroll to (beyond visible rows), the .row property returns the number of the row that is now visible. So, let’s say the number of visible rows is 12. User scrolls to see #13, and when clicks on it, it will return a row number based upon where it is in the visible rows-I.e. if user only scrolled once to get that 13th row, and clicks, it will show 13, where as it is really the 14th row (because the grid starts at 0). I know that sounds confusing, but try one. You’ll see.
if user keeps scrolling until the first hidden row is now on the top, clicking it will show 0 in the .Row property.
as I said earlier, flex grids are so much more, well, flexible!
Sam I am (as well as Confused at times).
-
Mar 4th, 2024, 03:14 PM
#8
Re: How to get the current ROW in datagrid in vb6
 Originally Posted by SamOscarBrown
Yes, but that is by code, I’d assume. When an item is selected that one has to scroll to (beyond visible rows), the .row property returns the number of the row that is now visible. So, let’s say the number of visible rows is 12. User scrolls to see #13, and when clicks on it, it will return a row number based upon where it is in the visible rows-I.e. if user only scrolled once to get that 13th row, and clicks, it will show 13, where as it is really the 14th row (because the grid starts at 0). I know that sounds confusing, but try one. You’ll see.
if user keeps scrolling until the first hidden row is now on the top, clicking it will show 0 in the .Row property.
as I said earlier, flex grids are so much more, well, flexible!
i decline the offer. 
haven‘t used databound controls in my vb6 time, am not using them now in my FreePascal time.
result: I don’t have to fight with such crap that only holds you back
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Mar 4th, 2024, 04:21 PM
#9
Re: How to get the current ROW in datagrid in vb6
vb6 usercontrol datagrid,A replacement for Microsoft's old version of the control should be able to do this. , rows property
After all, this is something invented by Microsoft in 1998. And Microsoft has a bad habit, the subsequent upgrade of things like vba, 10 years and 20 years, almost no increase in functionality
Vs flexgrid. OCX, this charge table controls to achieve all of these functions, of course, the cost is also more expensive.
-
Mar 4th, 2024, 04:25 PM
#10
Re: How to get the current ROW in datagrid in vb6
 Originally Posted by Zvoni
i decline the offer. 
haven‘t used databound controls in my vb6 time, am not using them now in my FreePascal time.
result: I don’t have to fight with such crap that only holds you back
Actually. Our common controls all have database binding function. Text box, can automatically read data, can be automatically modified.
Bind an Adobe recordset directly to a Grid control. In this way, you can directly modify the database by modifying the content in the cell.
Adodc can see the current line of all record functions, jump to the previous line and operate on the next line. It's actually very convenient.
-
Mar 4th, 2024, 04:29 PM
#11
Re: How to get the current ROW in datagrid in vb6
datagrid_rowcolchange(lastrow),Here you can get the line number position of the last time. But you can't get the current line number position. If you change the data in one cell, it will not be saved automatically until you switch to the next cell.
There is one drawback to this space. A method to save the data is missing.
If you use the same technology as hackers to achieve it. For example, switch to the next cell and return to the previous cell.
In this way, the data can be saved. The function of reading the current row number.
Like Vb6's collection object, you can't get all the keyword list arrays.Someone used a hacker's method to get the complete data from the memory.
So in theory, the grid control should have a way to find the current row number data in memory.
For example, we can bind a table with 8000 rows of data. If we move to line 1356. Search for 1356 or 1355 in memory. Maybe we can find a memory offset.
datagrid1.VisibleRows
recordset.recordcount
DataGrid1.ApproxCount
rs.AbsolutePosition
rs.bookmark
After deleting a record, can the exact line number still be displayed?
Last edited by xiaoyao; Mar 4th, 2024 at 04:57 PM.
-
Mar 4th, 2024, 05:14 PM
#12
Re: How to get the current ROW in datagrid in vb6
Not holding ME back...was just trying to answer x's question...I don't use DataGrids at all. :-)
Sam I am (as well as Confused at times).
-
Mar 4th, 2024, 05:51 PM
#13
Re: How to get the current ROW in datagrid in vb6
If you need to quickly display a table that can be edited and modified to a database, this control is really useful.
Like an excel spreadsheet.It is convenient to add, delete and modify data.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|