// change the cursor over a link private void c1TrueDBGrid1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { Cursor cursor = Cursors.Default; int row, col; if (this.c1TrueDBGrid1.CellContaining(e.X, e.Y, out row, out col)) { C1.Win.C1TrueDBGrid.C1DisplayColumn dispcol = this.c1TrueDBGrid1.FocusedSplit.DisplayColumns[col]; Hyperlink link = this.c1TrueDBGrid1[row, dispcol.DataColumn.DataField] as Hyperlink; if (link != null) { using (Graphics g = this.c1TrueDBGrid1.CreateGraphics()) { Rectangle r = this.c1TrueDBGrid1.Splits[0].GetCellBounds(row, col); int width = (int)g.MeasureString(link.ToString(), this.c1TrueDBGrid1.Font).Width; if (e.X - r.Left <= width) { cursor = Cursors.Hand; } } } } this.c1TrueDBGrid1.Cursor = cursor; }
// go to the link private void c1TrueDBGrid1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (this.c1TrueDBGrid1.Cursor == Cursors.Hand) { int row, col; if (this.c1TrueDBGrid1.CellContaining(e.X, e.Y, out row, out col)) { C1.Win.C1TrueDBGrid.C1DisplayColumn dispcol = this.c1TrueDBGrid1.FocusedSplit.DisplayColumns[col]; Hyperlink link = this.c1TrueDBGrid1[row, dispcol.DataColumn.DataField] as Hyperlink; if (link != null) { link.Activate(); } } } }