views:

368

answers:

2

Hi In Delphi I've managed (!) to add a column to a TcxGrid table view that appears as a hyperlink (instead of a simple string). To do this, you simply edit 'properties' of the column and choose 'hyperlink'. The cell now shows a hyperlink style (underlined) but I canot for the life of me see how to:

  1. Get the cursor to change to the 'hand' when over the link.
  2. Add an event that is fired when I click the link.

Can anyone help? Thanks.

A: 

Click the column header, the column is selected.

Goto 'Events'

Properties - OnStartClick -> this event is fired when you click an url

On my delphi 7 system with latest dev.express installed, the cursor is changed to a hand when an url is present.

I zipped my Dephi 7 sample program and executable so you see the complete project your self (the download of from my own site www.edelcom.com)

  • run the exec
  • press the insert button at the bottom
  • enter url: www.google.com
  • press enter
  • move over the link - the hand appears, and clicking the link, shows a message 'clicked' , if you don't have the click event, it starts the clicked url (maybe it can do that too, but I haven't tried this)
Edelcom
@Edelcom: THanks for the hint but I'm still struggling. I dont get the hand and I dont get the OnStartClick event fired. I've preset the text string to a www.something.com but although this displays, it's not 'hot'. Do you have a mouse event to get the hand? Could you tell me what properties you have set?
Brian Frost
@brian frost: I updated my answer to include a link to the very small project I tried. It's in Delphi 7.
Edelcom
@Edelcom: Thanks that works. It would be nice to have built-in hyperlink activity though.
Brian Frost
@Edelcom: That's excellent. The problem was a property called 'SingleClick' which defaults to false and no hand. You had it true, now so have I :-)
Brian Frost
+1  A: 

After you set the properties to Hyperlink, you can expand the properties. Set the SiongleClick property to True for activation with one click.

To change the cursor is more difficult. You will have to react on a mousemove event and determine if the mouse is hoovering over a hyperlink column. From the DevExpress site:

procedure TForm1.cxGrid1DBTableView1MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
var
  Ht: TcxCustomGridHitTest;
begin
  Ht := TcxGridSite(Sender).GridView.Viewinfo.GetHitTest(X,Y);
  If (Ht is TcxGridRecordCellHitTest) and
   (TcxGridRecordCellHitTest(Ht).Item.Properties is TcxHyperLinkEditProperties) then
    Screen.Cursor := crHandPoint
  else
    Screen.Cursor := crDefault;
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if Screen.Cursor <> crDefault then
     Screen.Cursor := crDefault;
end;
birger
Dev.Express should build this in in their component. Especially for a hyperlink (although in my test project with a normal non db table, the hand appears automatically (I think you need to include http: , though).
Edelcom