jwcolby
jwcolby at colbyconsulting.com
Sat Dec 4 16:26:43 CST 2010
I am defining a system for displaying a status on a form. We have a listview object, in which we
create three columns, then push stuff into the list using the following coed:
private void UpdateStage1Status(StatusEventArgs stEvArgs)
{
Font bold = new Font(Font, FontStyle.Bold); //to make the font bold
ListViewItem item;
item = lstvStatus.Items.Add("",stEvArgs.pImageIndex); //The image to display for the row
//item.BackColor = stEvArgs.pColor;
item.UseItemStyleForSubItems = false; //need to set this to allow changing font color
item.SubItems.Add(stEvArgs.pDte.ToString()); //date
item.SubItems.Add(stEvArgs.pObjectPath); //object path
item.SubItems.Add(stEvArgs.pStatus, Color.Black, Color.White, bold); //status text
}
Now I want to wrap the list and this code in a class so that I do not have to have all this (and
other) stuff in the form.
The problem is that the line
Font bold = new Font(Font, FontStyle.Bold); //to make the font bold
won't compile in a class. It complains that
Font bold = new Font(Font
That last class is bad (can't be inherited). AFAICT (just a guess) that Font reference only works
in a form.
Is there any way other than passing the font in to this method to us the code as written (in a class)?
--
John W. Colby
www.ColbyConsulting.com