StrataFrame Forum

How to change listview items fonts?

http://forum.strataframe.net/Topic24662.aspx

By Edhy Rijo - 9/18/2009

I have a SF listview and want to change the font for its items, I though that by changing the font in the listview will take care of that, but nope, it will only change the font for the columns.



Then I try in the OnLoad with the following code:



Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)

MyBase.OnLoad(e)



'-- Change the font of the listview items

For Each item As ListViewItem In Me.lstItemsStock.Items

item.Font = New System.Drawing.Font("Segoe UI", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

Next



End Sub





That did not work either, so here is the question: How to change the font for the ListViewItems in the SF ListView?
By Edhy Rijo - 9/18/2009

Never mind, I found it after looking at the obvious for other settings in the ListView "RowPopulated" event.



Here is the code...







Dim myListViewItemFont As Object = New System.Drawing.Font("Segoe UI", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))



Private Sub lstItemsStock_RowPopulated(ByVal sender As System.Object, ByVal e As MicroFour.StrataFrame.UI.Windows.Forms.RowPopulatedEventArgs) Handles lstItemsStock.RowPopulated

e.ListViewItem.Font = myListViewItemFont



End Sub

By Trent L. Taylor - 9/20/2009

Yup, that was the very reason that we added that method, to expose the entire list item so you can do whatever necessary. Good find Wink