C1 Community
ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

TDBGrid - Selecting Certain Row Number

rated by 0 users
This post has 3 Replies | 1 Follower

Not Ranked
Posts 6
thaburner Posted: Wed, Sep 24 2008 6:41 PM

I'm trying to select a certain row and then highlight it, basically at run time if i click on my graph and it returns an X Axis value of 5 I want to select Row 5 and move the Vertical scroll bar so you can see that row if it is not visible on the TDBGrid.  I have tried to find this in the help files and on the forum but no luck.

 

Top 25 Contributor
Posts 666
C1_DaveT replied on Fri, Sep 26 2008 5:14 AM

Any given row can be selected by setting SelBookmarks object.

 

As you also want grid to scroll to show the selected row, you can use FirstRow property of grid for this purpose.

 

Following is a sample code snippet showing both of these –

------------------------

Private Sub Command1_Click()

 

  Dim SelBks As TrueOleDBGrid80.SelBookmarks

 

 

 Set SelBks = Me.TDBGrid1.SelBookmarks

   

 'Set 28th row selected

  SelBks.Add 28

 

'Scroll to the 28th row

Me.TDBGrid1.FirstRow = 28

 

End Sub

--------------------------

 

-Dave.

 

<thaburner> wrote in message news:209285@10.0.1.98...

I'm trying to select a certain row and then highlight it, basically at run time if i click on my graph and it returns an X Axis value of 5 I want to select Row 5 and move the Vertical scroll bar so you can see that row if it is not visible on the TDBGrid.  I have tried to find this in the help files and on the forum but no luck.

 



http://helpcentral.componentone.com/cs/forums/p/76670/209285.aspx#209285

Not Ranked
Posts 6
thaburner replied on Thu, Oct 9 2008 10:20 AM

 Dave,

 Thank You that did the trick.

 Is there anyway to set the posistion of the row that is selected as well. For example 10 Rows are visible and i want the selected row to always be shown on the 5th (in the middle) visible row. So that way the user can always see 4 before and 4 after rows of the selected row.

Top 25 Contributor
Posts 456
Hello,
 
You may get the total number of visible row by maxcount property of the grid, and set the bookmark of the selected row to maxcount/2.
 
I hope this helps.
 
Have a nice day.
 
Regards,
James Smith
<thaburner> wrote in message news:209713@10.0.1.98...

 Dave,

 Thank You that did the trick.

 Is there anyway to set the posistion of the row that is selected as well. For example 10 Rows are visible and i want the selected row to always be shown on the 5th (in the middle) visible row. So that way the user can always see 4 before and 4 after rows of the selected row.



http://helpcentral.componentone.com/cs/forums/p/76670/209713.aspx#209713

Page 1 of 1 (4 items) | RSS
Contact ComponentOne: 1.800.858.2739 ©1987-2010 ComponentOne LLC All Rights Reserved.