Print Page | Close Window

How to get the value item to font....

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Property Grid
Forum Description: Topics Related to Codejock Property Grid
URL: http://forum.codejock.com/forum_posts.asp?TID=4235
Printed Date: 27 November 2024 at 5:31am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to get the value item to font....
Posted By: wizzy
Subject: How to get the value item to font....
Date Posted: 17 May 2006 at 9:03pm

Hi,

On my PropertyGrid I have added a item of type font , with the following code:

PropertyGridItemFont ItemFont = (PropertyGridItemFont)Category.AddChildItem(PropertyItemType .PropertyItemFont "FontItem", this.Font.ToHfont().ToInt32());

ItemFont.Color = 0xFF0000;

But at time to retrieve the value with the event ValueChanged, It will generate an exception. The code that I am using to get the value is as follow:

Font result= (Font)e.item.Value;

 

Can you tell me the correct way to get the value using C#?




Replies:
Posted By: Oleg
Date Posted: 18 May 2006 at 9:30am

e.item.Value is ActiveX STDFont object - you can't change it's type to managed Font.

Here code you can try:

if (e.item.Type == PropertyItemType.PropertyItemFont)

{

   PropertyGridItemFont FontItem = e.item as PropertyGridItemFont;

   Font fnt = new Font(FontItem.FontFaceName, FontItem.FontSize);

   chkCustomColors.Font = fnt;

}

 



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net