Topic: Clickable Link column in tGrid?
Is it possible to have clickable link column/s in tGrid for URL / Email addresses?
God... please help me become the person my dog thinks I am.
My Visual Database → General → Clickable Link column in tGrid?
Is it possible to have clickable link column/s in tGrid for URL / Email addresses?
Clickable URL/Email for first column,
procedure Form1_TableGrid1_OnCellClick (Sender: string; ACol, ARow: Integer);
begin
if ACol=0 then
if Pos('@', Form1.TableGrid1.Cells[ACol,ARow]) > 0 then
OpenUrl('mailto:'+Form1.TableGrid1.Cells[ACol,ARow])
else OpenUrl(Form1.TableGrid1.Cells[ACol,ARow]);
end;
Hi Dmitry,
Thank you very much..................
Truly appreciated........................
After trial and error (replacing @ with www for a URL), I think, I managed to have URL and Email links on separate columns:
procedure FORM2_TableGrid3_OnCellClick (Sender: string; ACol, ARow: Integer);
begin
if ACol=1 then
if Pos('www', Form2.TableGrid3.Cells[ACol,ARow]) > 0 then
OpenUrl(Form2.TableGrid3.Cells[ACol,ARow]);
if ACol=2 then
if Pos('@', Form2.TableGrid3.Cells[ACol,ARow]) > 0 then
OpenUrl('mailto:'+Form2.TableGrid3.Cells[ACol,ARow])
end;
If the above is incorrect, please correct.
Link may be without 'www', better to use 'http' to check link.
Link may be without 'www', better to use 'http' to check link.
Good point.
However, user may just type www.myvisualdatabase.com instead of c/p or type full url http://myvisualdatabase.com/index.html
Plus there are urls with https such as https://www.google.com
If possible best solution would be to include all 3 by making the following line to work:
if Pos('https' or 'http' or 'www', Form2.TableGrid3.Cells[ACol,ARow]) > 0 then
if (Pos('http', Form2.TableGrid3.Cells[ACol,ARow]) =1) or (Pos('www', Form2.TableGrid3.Cells[ACol,ARow]) =1) then
Thank you very much Dmitry................
Taking it bit further, I wanted apply couple more features to clickable linked URLs and Emails
♦ Coloring linked columns: Works fine
♦ Underlining linked items: Not working
♦ Changing mouse to crHandPoint when mouse moves over a linked item: Not working.
I tried the following but I think I couldn't get the syntax right except coloring part:
procedure FORM2_TableGrid3_OnChange (Sender: string); // Selected whole column Text Coloring
var vc, vi: integer;
begin
vc := FORM2.TableGrid3.rowcount-1;
for vi := 0 to vc do
begin
FORM2.TableGrid3.cell[1,vi].textcolor := clblue;
FORM2.TableGrid3.cell[2,vi].textcolor := clblue;
FORM2.TableGrid3.cell[1,vi].FontStyle := Underlined;
end;
end;
procedure FORM2_TableGrid3_OnMouseEnter (Sender: string);
var vc, vi: integer;
begin
vc := FORM2.TableGrid3.rowcount-1;
for vi := 0 to vc do
begin
FORM2.TableGrid3.cell[1,vi].Cursor := crHandPoint;
FORM2.TableGrid3.cell[2,vi].Cursor := crHandPoint;
end;
end;
change
FORM2.TableGrid3.cell[1,vi].FontStyle := Underlined;
to
FORM2.TableGrid3.cell[1,vi].FontStyle := fsUnderline;
You can change cursor only for whole column
FORM2.TableGrid3.Columns[0].Cursor := crHandPoint;
Thank you very much for your kind help Dmitry.......................
I tried to add couple of lines to have cursor turns into handpoint only when there is a link item within a cell
procedure FORM2_TableGrid3_OnMouseEnter (Sender: string);
var ACol, ARow: Integer;
begin
if (Pos('http', Form2.TableGrid3.Cells[ACol,ARow]) =1) or (Pos('www', Form2.TableGrid3.Cells[ACol,ARow]) =1) then
begin
FORM2.TableGrid3.Columns[1].Cursor := crHandPoint;
end;
if Pos('@', Form2.TableGrid3.Cells[ACol,ARow]) > 0 then
begin
FORM2.TableGrid3.Columns[2].Cursor := crHandPoint;
end;
end;
However, it didn't work as usual
Your script is wrong, you can use it only in this way:
procedure Form1_TableGrid1_OnChange (Sender: string);
begin
Form1.TableGrid1.Columns[0].Cursor := crHandPoint;
end;
My Visual Database → General → Clickable Link column in tGrid?
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi