Mr_Fulano
asked on
Changing Font in DataGridView
Hi, I'm using VB 2005, WinForms. I have a DataGridView that contains a list of users. Some users are "active" users and some are "inactive." I use a BindingSource Filter to show each type. -- All that works great.
However, for the sake of clarity, I'd like to change the Font of the "inactive" users to a font with a "strike-through" line. Hence, showing that the user has been crossed out or removed from the list in some graphic manner.
How can I change my DataGridView's Font to "strike-through"?
I tried >> dgvMyUsers.Font.Strikeout = True , but that doesn't work. It gets a squiggly blue line under it. What's missing?
Thanks for your help,
Fulano
However, for the sake of clarity, I'd like to change the Font of the "inactive" users to a font with a "strike-through" line. Hence, showing that the user has been crossed out or removed from the list in some graphic manner.
How can I change my DataGridView's Font to "strike-through"?
I tried >> dgvMyUsers.Font.Strikeout = True , but that doesn't work. It gets a squiggly blue line under it. What's missing?
Thanks for your help,
Fulano
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi HBHoffman,
I figured it out...its:
dgvMyUsers.Font = New Font(dgvMyUsers.Font, FontStyle.Strikeout)
I'll award you the points for trying to help...thanks anyways!
Fulano
I figured it out...its:
dgvMyUsers.Font = New Font(dgvMyUsers.Font, FontStyle.Strikeout)
I'll award you the points for trying to help...thanks anyways!
Fulano
ASKER
The solution is not what worked for me. Please see my post below for a solution to my question that I worked out myself. -- Thanks for trying!!!
ASKER
NOTE: Here is a version of HBHoffman's code that will change only the "Inactive" records.
In my code an empty string is equal to an active user.
HBHoffman's code was good, but I needed to play with it to make it work for my needs. However, HBHoffman did a great job in trying to help me an in producing code that helped me get to where I needed to get to.
Thanks again,
Fulano
In my code an empty string is equal to an active user.
HBHoffman's code was good, but I needed to play with it to make it work for my needs. However, HBHoffman did a great job in trying to help me an in producing code that helped me get to where I needed to get to.
Thanks again,
Fulano
Private Sub DataGridView1_RowsAdded(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowsAddedEventArgs) Handles DataGridView1.RowsAdded
For Each r1 As DataGridViewRow In DataGridView1.Rows
For Each cell As DataGridViewCell In r1.Cells
If r1.Cells("CurrentStatus").Value.ToString Is String.Empty Then
cell.Style.Font = New Font("Microsoft San Serif", 8, FontStyle.Regular)
Else
cell.Style.Font = New Font("Microsoft San Serif", 8, FontStyle.Strikeout)
End If
Next
Next
End Sub
Yea, I wasn't sure what condition constituted an "inactive" user. I probably should have included the code that demonstrates how to test cell values. Glad you got it fugured out.
ASKER
I was able to figure it out only with your help HBHoffman. Thank you for your assistance as it was very valuable.
Fulano
Fulano
ASKER
There has to be something in my code below that intelli-sense doesn't like or that is missing.
dgvMyUsers.Font.Strikeout = True
Thanks for your help,
Fulano