|
|
 |
Author |
Message |
ron nash

|
Posted: Visual Basic Express Edition, List View Font setting |
Top |
Hi,
How do I set the font of all items in a listview control in code.
I can set the listview Group Header font like this:
But fail to find away to change the items in the list.
Dim fontFamily As New FontFamily("Arial")
Dim font As New Font(fontFamily, 30, FontStyle.Strikeout, GraphicsUnit.Pixel)
Form1.ListAccounts.Font = font
Ron
Visual Studio Express Editions2
|
|
|
|
 |
DMan1

|
Posted: Visual Basic Express Edition, List View Font setting |
Top |
The font property of the listview controls the items font as well as the header font...the following code will change the font of the column headers as well as the items in the listview:
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.ListView1.Font = New Font("Arial", 18)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.ListView1.Font = New Font("Times", 10)
Me.ListView1.Items.Add("Item1")
Me.ListView1.Items.Add("Item2")
End Sub
|
|
|
|
 |
ron nash

|
Posted: Visual Basic Express Edition, List View Font setting |
Top |
Thanks for the reply
This is what I need the code to do:
I have a list view with a number of items that when the mouse hovers over them, or the item is selected, it becomes underlined.
I need a way to remove the underline from the selected item .
Ron
|
|
|
|
 |
ron nash

|
Posted: Visual Basic Express Edition, List View Font setting |
Top |
Sorted,
Dim fontFamily As New FontFamily("Microsoft Sans Serif")
Dim font As New Font(fontFamily, 10, FontStyle.Regular)
Dim a As Integer = Form1.ListAccounts.Items.Count
Dim b As Integer
For b = 0 To a - 1
Form1.ListAccounts.Items(b).Font = font
Next
|
|
|
|
 |
DMan1

|
Posted: Visual Basic Express Edition, List View Font setting |
Top |
The following code will underline only the selected item in the listview:
Dim TheFont As New Font("Arial", 10, FontStyle.Regular)
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.ListView1.Font = TheFont
Me.ListView1.Items.Add("Item1")
Me.ListView1.Items.Add("Item2")
End Sub
Private Sub ListView1_ItemSelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles ListView1.ItemSelectionChanged
If e.IsSelected Then
e.Item.Font = New Font(e.Item.Font, FontStyle.Regular Or FontStyle.Underline)
Else
e.Item.Font = TheFont
End If
End Sub
|
|
|
|
 |
|
|