[dba-VB] use a font in a class

Shamil Salakhetdinov shamil at smsconsulting.spb.ru
Sat Dec 4 17:46:51 CST 2010


But you can pass form's Font instance to your class as a parameter, dont'
you?...

Or you can create a Font instance in your class, don't you?

Thank you.

--
Shamil
 
-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: 5 ??????? 2010 ?. 2:28
To: Discussion concerning Visual Basic and related programming issues.
Subject: Re: [dba-VB] use a font in a class

Yes, in a form that works because "this" has a font.  In a class, "this" is
the class (not a form) which doesn't have a font.

John W. Colby
www.ColbyConsulting.com

On 12/4/2010 5:55 PM, Shamil Salakhetdinov wrote:
> John  --
>
> You can use:
>
>   Font font = new Font(this.Font, FontStyle.Bold);
>
> Ignore my prev. posting in this thread.
>
> Thank you.
>
> --
> Shamil
>
> -----Original Message-----
> From: dba-vb-bounces at databaseadvisors.com
> [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
> Sent: 5 ??????? 2010 ?. 1:27
> To: VBA
> Subject: [dba-VB] use a font in a class
>
> 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
> _______________________________________________
> dba-VB mailing list
> dba-VB at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-vb
> http://www.databaseadvisors.com
>
> _______________________________________________
> dba-VB mailing list
> dba-VB at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-vb
> http://www.databaseadvisors.com
>
>
_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com




More information about the dba-VB mailing list