Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 09-29-2005, 05:21 AM
geolobo geolobo is offline
Member
 
Join Date: Sep 2005
Posts: 50
Default simulate clicking DBGrid Rows by source?

I have a DBGird showing some records.

I need to simulate clicking the first record (or any row for that matter) by code (Source)

I have tried using SelectedIndex of the DBGrid with SetFocus and dont work
Reply With Quote
  #2  
Old 09-29-2005, 07:11 AM
mtveerman mtveerman is offline
Senior Member
 
Join Date: Mar 2002
Posts: 155
Default RE: simulate clicking DBGrid Rows by source?

Why? Is something happening when a user clicks the first row?
If a user clicks the first row, it basically means the focus in the dataset is set to the first record in that dataset.
So I think you should look there for the answer. Something like: DataSet.RecNo:=0; Maybe you cannot assign to RecNo, but in that case there must be some procedure to get the same result. For example: Dataset.First;
After doing this, call the function that would normally be activated when the user clicks the DBGrid

Maarten Veerman
Reply With Quote
  #3  
Old 09-29-2005, 07:15 AM
geolobo geolobo is offline
Member
 
Join Date: Sep 2005
Posts: 50
Default RE: simulate clicking DBGrid Rows by source?

No that is not the case

when I start my app - my dbgrid automatically highlights the first row in the grid - however, i have code based off from the Grids selectedrows.count property - this is not officially showing the correct value unless I click the row - I need on startup, for this property to have that value - therefore, I need to simulate by code the clicking of the first row (or any row for that matter)
Reply With Quote
  #4  
Old 09-29-2005, 10:59 PM
mtveerman mtveerman is offline
Senior Member
 
Join Date: Mar 2002
Posts: 155
Default RE: simulate clicking DBGrid Rows by source?

So it doesn't matter what row to click? You just want to simulate a click on the DBGrid?

Can't you simply do something like: DBGrid1.Click ?
Else you'll need to send a message, like:
DBGrid1.Perform(WM_MOUSEDOWN,0,0);

(See the docs on the Perform function. I'm sure the parameters I supplied here are not correct....)


Maarten Veerman
Reply With Quote
  #5  
Old 09-30-2005, 04:05 AM
douglas douglas is offline
Senior Member
 
Join Date: Jul 2001
Posts: 7,695
Default RE: simulate clicking DBGrid Rows by source?

Yeah, I wish it was that easy - tried that -

and no, there is no DBGrid click method or OnClick event



If this helps, please accept as answer!

Thanks!

UnSysApps
Reply With Quote
  #6  
Old 10-03-2005, 09:42 AM
mtveerman mtveerman is offline
Senior Member
 
Join Date: Mar 2002
Posts: 155
Default RE: simulate clicking DBGrid Rows by source?

As I said, have a look at the Perform method to send a message to the control.

Now that I'm behind a computer with Delphi I could try the following code, and it worked for me:

DBGrid1.Perform(WM_LBUTTONDOWN,0,0);


Maarten Veerman
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:42 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.