开发者

How to add a hyperlink column to a TcxGrid (Developer express grid)

Hi In Delphi I've ma开发者_JAVA百科naged (!) 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.


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;


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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜