Change mouse cursor when points to specific cell

G

Guest

I am creating a linklabel look-a-link in a datagrid with the following code
by overriding the paint sub:

If column = 0 Or column = 3 Or column = 4 Then

Dim UnderlineFont As New
Font(Me.DataGridTableStyle.DataGrid.Font, FontStyle.Underline)
Dim rect As Rectangle = bounds
Dim value As Object = GetColumnValueAtRow(source, rowNum)
g.FillRectangle(backBrush, rect)
g.DrawString(value.ToString, UnderlineFont, Brushes.Blue,
RectangleF.FromLTRB(rect.X, rect.Y, rect.Right, rect.Bottom))

Else
MyBase.Paint(g, bounds, source, rowNum, backBrush,
foreBrush, alignToRight)
End If

I only create the linklabel look-alike in specific rows and columns. Now I
have to have the cursor change to a 'hand' when the mouse moves over a cell.
Note! I am creating the datagrid programmatically so I do not know what rows
will contain a link (so I can not use the example by George Shepard in
sycfusion). Also, there is NOT a mouseup or mousedown event to work with. I
only want the cursor to change to a hand on a specific cell, not a whole row.

I have been trying to do with with the datagrid.hittestinfo but can't seem
the to get it.

Thanks!
 
M

Madhavi

Suz,

Try subclassing the DataGrid and override OnMouseEnter method. It the column
is of Type LinkLabelColumn then change the cursor style. This is what I did
for the Look a like linkLabel in my inherited DataGrid.

protected override void OnMouseMove(MouseEventArgs e){

DataGrid.HitTestInfo hti = HitTest(e.X, e.Y);

switch (hti.Type)

{

case DataGrid.HitTestType.Cell:

if
(TableStyles[0].GridColumnStyles[hti.Column].GetType().Name.Equals("LinkLabelColumn"))

{

this.Cursor = Cursors.Hand;

}

else

{

this.Cursor = Cursors.Arrow;

}

break;

}

}
 
G

Guest

Hi Madhavi!

Thank you! It works ..... would you happen to know how I can interrigate the
contents of the cell to find out if it is blank or has a value. If it is
blank, then I do no want it to have a hand cursor.
The screen looks something like this

FileID
Date Owner Project
Date Owner Project

So that every row in the FileID column has a 'linklabelcolumn'. The cursor
is a hand over the whole FileID column. I think that if I can find the
value in the in the cell, then I can change the cursor style based on the
contents of the cell.

Again, thank you!


Madhavi said:
Suz,

Try subclassing the DataGrid and override OnMouseEnter method. It the column
is of Type LinkLabelColumn then change the cursor style. This is what I did
for the Look a like linkLabel in my inherited DataGrid.

protected override void OnMouseMove(MouseEventArgs e){

DataGrid.HitTestInfo hti = HitTest(e.X, e.Y);

switch (hti.Type)

{

case DataGrid.HitTestType.Cell:

if
(TableStyles[0].GridColumnStyles[hti.Column].GetType().Name.Equals("LinkLabelColumn"))

{

this.Cursor = Cursors.Hand;

}

else

{

this.Cursor = Cursors.Arrow;

}

break;

}

}

Suz said:
I am creating a linklabel look-a-link in a datagrid with the following code
by overriding the paint sub:

If column = 0 Or column = 3 Or column = 4 Then

Dim UnderlineFont As New
Font(Me.DataGridTableStyle.DataGrid.Font, FontStyle.Underline)
Dim rect As Rectangle = bounds
Dim value As Object = GetColumnValueAtRow(source, rowNum)
g.FillRectangle(backBrush, rect)
g.DrawString(value.ToString, UnderlineFont, Brushes.Blue,
RectangleF.FromLTRB(rect.X, rect.Y, rect.Right, rect.Bottom))

Else
MyBase.Paint(g, bounds, source, rowNum, backBrush,
foreBrush, alignToRight)
End If

I only create the linklabel look-alike in specific rows and columns. Now I
have to have the cursor change to a 'hand' when the mouse moves over a
cell.
Note! I am creating the datagrid programmatically so I do not know what
rows
will contain a link (so I can not use the example by George Shepard in
sycfusion). Also, there is NOT a mouseup or mousedown event to work with.
I
only want the cursor to change to a hand on a specific cell, not a whole
row.

I have been trying to do with with the datagrid.hittestinfo but can't seem
the to get it.

Thanks!
 
G

Guest

Hi Madhavi!

Thank you! It works ..... would you happen to know how I can interrigate the
contents of the cell to find out if it is blank or has a value. If it is
blank, then I do no want it to have a hand cursor.
The screen looks something like this

FileID
Date Owner Project
Date Owner Project

So that every row in the FileID column has a 'linklabelcolumn'. The cursor
is a hand over the whole FileID column. I think that if I can find the
value in the in the cell, then I can change the cursor style based on the
contents of the cell.

Again, thank you!


Madhavi said:
Suz,

Try subclassing the DataGrid and override OnMouseEnter method. It the column
is of Type LinkLabelColumn then change the cursor style. This is what I did
for the Look a like linkLabel in my inherited DataGrid.

protected override void OnMouseMove(MouseEventArgs e){

DataGrid.HitTestInfo hti = HitTest(e.X, e.Y);

switch (hti.Type)

{

case DataGrid.HitTestType.Cell:

if
(TableStyles[0].GridColumnStyles[hti.Column].GetType().Name.Equals("LinkLabelColumn"))

{

this.Cursor = Cursors.Hand;

}

else

{

this.Cursor = Cursors.Arrow;

}

break;

}

}

Suz said:
I am creating a linklabel look-a-link in a datagrid with the following code
by overriding the paint sub:

If column = 0 Or column = 3 Or column = 4 Then

Dim UnderlineFont As New
Font(Me.DataGridTableStyle.DataGrid.Font, FontStyle.Underline)
Dim rect As Rectangle = bounds
Dim value As Object = GetColumnValueAtRow(source, rowNum)
g.FillRectangle(backBrush, rect)
g.DrawString(value.ToString, UnderlineFont, Brushes.Blue,
RectangleF.FromLTRB(rect.X, rect.Y, rect.Right, rect.Bottom))

Else
MyBase.Paint(g, bounds, source, rowNum, backBrush,
foreBrush, alignToRight)
End If

I only create the linklabel look-alike in specific rows and columns. Now I
have to have the cursor change to a 'hand' when the mouse moves over a
cell.
Note! I am creating the datagrid programmatically so I do not know what
rows
will contain a link (so I can not use the example by George Shepard in
sycfusion). Also, there is NOT a mouseup or mousedown event to work with.
I
only want the cursor to change to a hand on a specific cell, not a whole
row.

I have been trying to do with with the datagrid.hittestinfo but can't seem
the to get it.

Thanks!
 
G

Guest

Hi Madhavi!

Thank you! It works ..... would you happen to know how I can interrigate the
contents of the cell to find out if it is blank or has a value. If it is
blank, then I do no want it to have a hand cursor.
The screen looks something like this

FileID
Date Owner Project
Date Owner Project

So that every row in the FileID column has a 'linklabelcolumn'. The cursor
is a hand over the whole FileID column. I think that if I can find the
value in the in the cell, then I can change the cursor style based on the
contents of the cell.

Again, thank you!


Madhavi said:
Suz,

Try subclassing the DataGrid and override OnMouseEnter method. It the column
is of Type LinkLabelColumn then change the cursor style. This is what I did
for the Look a like linkLabel in my inherited DataGrid.

protected override void OnMouseMove(MouseEventArgs e){

DataGrid.HitTestInfo hti = HitTest(e.X, e.Y);

switch (hti.Type)

{

case DataGrid.HitTestType.Cell:

if
(TableStyles[0].GridColumnStyles[hti.Column].GetType().Name.Equals("LinkLabelColumn"))

{

this.Cursor = Cursors.Hand;

}

else

{

this.Cursor = Cursors.Arrow;

}

break;

}

}

Suz said:
I am creating a linklabel look-a-link in a datagrid with the following code
by overriding the paint sub:

If column = 0 Or column = 3 Or column = 4 Then

Dim UnderlineFont As New
Font(Me.DataGridTableStyle.DataGrid.Font, FontStyle.Underline)
Dim rect As Rectangle = bounds
Dim value As Object = GetColumnValueAtRow(source, rowNum)
g.FillRectangle(backBrush, rect)
g.DrawString(value.ToString, UnderlineFont, Brushes.Blue,
RectangleF.FromLTRB(rect.X, rect.Y, rect.Right, rect.Bottom))

Else
MyBase.Paint(g, bounds, source, rowNum, backBrush,
foreBrush, alignToRight)
End If

I only create the linklabel look-alike in specific rows and columns. Now I
have to have the cursor change to a 'hand' when the mouse moves over a
cell.
Note! I am creating the datagrid programmatically so I do not know what
rows
will contain a link (so I can not use the example by George Shepard in
sycfusion). Also, there is NOT a mouseup or mousedown event to work with.
I
only want the cursor to change to a hand on a specific cell, not a whole
row.

I have been trying to do with with the datagrid.hittestinfo but can't seem
the to get it.

Thanks!
 
G

Guest

Hi Madhavi!

Thank you! It works ..... would you happen to know how I can interrigate the
contents of the cell to find out if it is blank or has a value. If it is
blank, then I do no want it to have a hand cursor.
The screen looks something like this

FileName
DateDone Owner Project
DateDone Owner Project

So that every row in the FileName column has a 'linklabelcolumn'. The cursor
is a hand over the whole FileName column. I think that if I can find the
value in the in the cell, then I can change the cursor style based on the
contents of the cell.

Again, thank you!


Madhavi said:
Suz,

Try subclassing the DataGrid and override OnMouseEnter method. It the column
is of Type LinkLabelColumn then change the cursor style. This is what I did
for the Look a like linkLabel in my inherited DataGrid.

protected override void OnMouseMove(MouseEventArgs e){

DataGrid.HitTestInfo hti = HitTest(e.X, e.Y);

switch (hti.Type)

{

case DataGrid.HitTestType.Cell:

if
(TableStyles[0].GridColumnStyles[hti.Column].GetType().Name.Equals("LinkLabelColumn"))

{

this.Cursor = Cursors.Hand;

}

else

{

this.Cursor = Cursors.Arrow;

}

break;

}

}

Suz said:
I am creating a linklabel look-a-link in a datagrid with the following code
by overriding the paint sub:

If column = 0 Or column = 3 Or column = 4 Then

Dim UnderlineFont As New
Font(Me.DataGridTableStyle.DataGrid.Font, FontStyle.Underline)
Dim rect As Rectangle = bounds
Dim value As Object = GetColumnValueAtRow(source, rowNum)
g.FillRectangle(backBrush, rect)
g.DrawString(value.ToString, UnderlineFont, Brushes.Blue,
RectangleF.FromLTRB(rect.X, rect.Y, rect.Right, rect.Bottom))

Else
MyBase.Paint(g, bounds, source, rowNum, backBrush,
foreBrush, alignToRight)
End If

I only create the linklabel look-alike in specific rows and columns. Now I
have to have the cursor change to a 'hand' when the mouse moves over a
cell.
Note! I am creating the datagrid programmatically so I do not know what
rows
will contain a link (so I can not use the example by George Shepard in
sycfusion). Also, there is NOT a mouseup or mousedown event to work with.
I
only want the cursor to change to a hand on a specific cell, not a whole
row.

I have been trying to do with with the datagrid.hittestinfo but can't seem
the to get it.

Thanks!
 
G

Guest

Madhavi!

I got it all working. Below is my modified code. Thanks so much for your
help. Sorry for the repeated posts. I get getting a bad verb error and didn't
realize my post was actually posting!

Private Sub dgMain_MouseMove( _
ByVal sender As Object, _
ByVal e As MouseEventArgs)
' **********************************
Dim hti As DataGrid.HitTestInfo = dgMain.HitTest(e.X, e.Y)
Select Case hti.Type
Case DataGrid.HitTestType.Cell
If
dgMain.TableStyles(0).GridColumnStyles(hti.Column).GetType.Name.Equals("DataGridColoredLinkLabel") Then
If dgMain.Item(hti.Row, hti.Column).ToString() <> "" Then
Me.Cursor = Cursors.Hand
Else
Me.Cursor = Cursors.Arrow
End If
Else
Me.Cursor = Cursors.Arrow
End If

End Select

End Sub

Suz said:
Hi Madhavi!

Thank you! It works ..... would you happen to know how I can interrigate the
contents of the cell to find out if it is blank or has a value. If it is
blank, then I do no want it to have a hand cursor.
The screen looks something like this

FileName
DateDone Owner Project
DateDone Owner Project

So that every row in the FileName column has a 'linklabelcolumn'. The cursor
is a hand over the whole FileName column. I think that if I can find the
value in the in the cell, then I can change the cursor style based on the
contents of the cell.

Again, thank you!


Madhavi said:
Suz,

Try subclassing the DataGrid and override OnMouseEnter method. It the column
is of Type LinkLabelColumn then change the cursor style. This is what I did
for the Look a like linkLabel in my inherited DataGrid.

protected override void OnMouseMove(MouseEventArgs e){

DataGrid.HitTestInfo hti = HitTest(e.X, e.Y);

switch (hti.Type)

{

case DataGrid.HitTestType.Cell:

if
(TableStyles[0].GridColumnStyles[hti.Column].GetType().Name.Equals("LinkLabelColumn"))

{

this.Cursor = Cursors.Hand;

}

else

{

this.Cursor = Cursors.Arrow;

}

break;

}

}

Suz said:
I am creating a linklabel look-a-link in a datagrid with the following code
by overriding the paint sub:

If column = 0 Or column = 3 Or column = 4 Then

Dim UnderlineFont As New
Font(Me.DataGridTableStyle.DataGrid.Font, FontStyle.Underline)
Dim rect As Rectangle = bounds
Dim value As Object = GetColumnValueAtRow(source, rowNum)
g.FillRectangle(backBrush, rect)
g.DrawString(value.ToString, UnderlineFont, Brushes.Blue,
RectangleF.FromLTRB(rect.X, rect.Y, rect.Right, rect.Bottom))

Else
MyBase.Paint(g, bounds, source, rowNum, backBrush,
foreBrush, alignToRight)
End If

I only create the linklabel look-alike in specific rows and columns. Now I
have to have the cursor change to a 'hand' when the mouse moves over a
cell.
Note! I am creating the datagrid programmatically so I do not know what
rows
will contain a link (so I can not use the example by George Shepard in
sycfusion). Also, there is NOT a mouseup or mousedown event to work with.
I
only want the cursor to change to a hand on a specific cell, not a whole
row.

I have been trying to do with with the datagrid.hittestinfo but can't seem
the to get it.

Thanks!
 
M

Madhavi

This was exactly what I was working on last week. So I could help you help
you.

Happy coding!!
Madhavi
Suz said:
Madhavi!

I got it all working. Below is my modified code. Thanks so much for your
help. Sorry for the repeated posts. I get getting a bad verb error and
didn't
realize my post was actually posting!

Private Sub dgMain_MouseMove( _
ByVal sender As Object, _
ByVal e As MouseEventArgs)
' **********************************
Dim hti As DataGrid.HitTestInfo = dgMain.HitTest(e.X, e.Y)
Select Case hti.Type
Case DataGrid.HitTestType.Cell
If
dgMain.TableStyles(0).GridColumnStyles(hti.Column).GetType.Name.Equals("DataGridColoredLinkLabel")
Then
If dgMain.Item(hti.Row, hti.Column).ToString() <> ""
Then
Me.Cursor = Cursors.Hand
Else
Me.Cursor = Cursors.Arrow
End If
Else
Me.Cursor = Cursors.Arrow
End If

End Select

End Sub

Suz said:
Hi Madhavi!

Thank you! It works ..... would you happen to know how I can interrigate
the
contents of the cell to find out if it is blank or has a value. If it is
blank, then I do no want it to have a hand cursor.
The screen looks something like this

FileName
DateDone Owner Project
DateDone Owner Project

So that every row in the FileName column has a 'linklabelcolumn'. The
cursor
is a hand over the whole FileName column. I think that if I can find
the
value in the in the cell, then I can change the cursor style based on the
contents of the cell.

Again, thank you!


Madhavi said:
Suz,

Try subclassing the DataGrid and override OnMouseEnter method. It the
column
is of Type LinkLabelColumn then change the cursor style. This is what I
did
for the Look a like linkLabel in my inherited DataGrid.

protected override void OnMouseMove(MouseEventArgs e){

DataGrid.HitTestInfo hti = HitTest(e.X, e.Y);

switch (hti.Type)

{

case DataGrid.HitTestType.Cell:

if
(TableStyles[0].GridColumnStyles[hti.Column].GetType().Name.Equals("LinkLabelColumn"))

{

this.Cursor = Cursors.Hand;

}

else

{

this.Cursor = Cursors.Arrow;

}

break;

}

}

I am creating a linklabel look-a-link in a datagrid with the following
code
by overriding the paint sub:

If column = 0 Or column = 3 Or column = 4 Then

Dim UnderlineFont As New
Font(Me.DataGridTableStyle.DataGrid.Font, FontStyle.Underline)
Dim rect As Rectangle = bounds
Dim value As Object = GetColumnValueAtRow(source,
rowNum)
g.FillRectangle(backBrush, rect)
g.DrawString(value.ToString, UnderlineFont,
Brushes.Blue,
RectangleF.FromLTRB(rect.X, rect.Y, rect.Right, rect.Bottom))

Else
MyBase.Paint(g, bounds, source, rowNum, backBrush,
foreBrush, alignToRight)
End If

I only create the linklabel look-alike in specific rows and columns.
Now I
have to have the cursor change to a 'hand' when the mouse moves over
a
cell.
Note! I am creating the datagrid programmatically so I do not know
what
rows
will contain a link (so I can not use the example by George Shepard
in
sycfusion). Also, there is NOT a mouseup or mousedown event to work
with.
I
only want the cursor to change to a hand on a specific cell, not a
whole
row.

I have been trying to do with with the datagrid.hittestinfo but can't
seem
the to get it.

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top