473,802 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Casting Font object into Element--- Need Help!!

18 New Member
Hi all

I really need a solution for the following::
-------------------------------------------------------------------------------------
Say i have a font object called 'myFont' as shown below;

Font myFont= domainAxis.getT ickLabelFont();

I need to cast "myFont" object into a "Element" object as i shown below

Element newFont = (Element)myFont ;

but this casting doesn't work; it is giving a Casting Exception; How can i cast a Font object in to an Element object?? Because i need to change attributes on that Element object and re-converted iy back to a Font object as below.
--------------------------------------------------------------------------------------
newFont.setAttr ibute("kerning" , "no");
newFont.setAttr ibute("family", "SansSerif" );
newFont.setAttr ibute("name","S ansSerif");
newFont.setAttr ibute("style"," plain");
newFont.setAttr ibute("size","1 0");

domainAxis.sets etTickLabelFont ((Font)newFont) ;

-------------------------------------------------------------------------------------

How to do the "Font " to "Element" Casting
Regards
Madumm
Jan 19 '07 #1
1 1215
r035198x
13,262 MVP
Hi all

I really need a solution for the following::
-------------------------------------------------------------------------------------
Say i have a font object called 'myFont' as shown below;

Font myFont= domainAxis.getT ickLabelFont();

I need to cast "myFont" object into a "Element" object as i shown below

Element newFont = (Element)myFont ;

but this casting doesn't work; it is giving a Casting Exception; How can i cast a Font object in to an Element object?? Because i need to change attributes on that Element object and re-converted iy back to a Font object as below.
--------------------------------------------------------------------------------------
newFont.setAttr ibute("kerning" , "no");
newFont.setAttr ibute("family", "SansSerif" );
newFont.setAttr ibute("name","S ansSerif");
newFont.setAttr ibute("style"," plain");
newFont.setAttr ibute("size","1 0");

domainAxis.sets etTickLabelFont ((Font)newFont) ;

-------------------------------------------------------------------------------------

How to do the "Font " to "Element" Casting
Regards
Madumm
Please do not double post. For a cast to work, the objects must be convertable.
i.e
Type2 b = new Type2();
Type1 a = (Type1) b;
For this to work, then class Type1 must extend Type2 directly or indirectly otherwise you get a class cast exception at runtime.
Jan 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2293
by: Philip K | last post by:
I was trying to use Soap serialisation to save some systems settings how ever it fails if the settings contain a Font object, works fine if the Font object is not in the object being serialised. Font is marked in the MS documentation. Exception has been thrown by the target of an invocation. at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
2
27674
by: Karl Meissner | last post by:
I am having problem casting from object. I want to pass in an value type as an object and then store it as a particular type. The cast from object throws an exception if the types do not match. class test { short x; // o can be any of the value types int, long, float public void Set( object o ) {
1
8911
by: Steven | last post by:
VB.NET Via the FontDialog I have retrieved a font. After saving the font (in an XML document) and retrieving it again, I have a string in the following "format"; How can I convert this string (back) to a font object? So that I can assign this to (for example) to: label1.Font = ....
5
3885
by: Diffident | last post by:
Hello All, I have a 2-dimensional array that I am storing as a session variable. I have no idea on how I can cast the session variable back to 2-dimensional array. Any pointers? Reference code below... Array declaration: DateTime DateRangesForDataLists = new DateTime;
2
6575
by: Patti | last post by:
I am building an application using VB.NET 1.1 and I have an issue with Font properties in my Radio Button Lists and Check Box Lists. My issue is that the Font Names and Font Size for these controls have become "Read Only" and I have no idea how they became read only. I didn't set anything to read only and was able to change these fonts just last week - so I must have messed something up. Below is a snippet of my HTML code I used...
1
1060
by: madumm | last post by:
Hi all I really need a solution for the following:: ------------------------------------------------------------------------------------- Font newFont= domainAxis.getTickLabelFont(); Element newFont = (Element)newFont; newFont.setAttribute("kerning", "no"); newFont.setAttribute("family","SansSerif"); newFont.setAttribute("name","SansSerif");
8
1981
by: Z1P2 | last post by:
Line 22 Char 1 says object expected in the following code. For the life of me I can't figure out what it is. I'm sure I'm just overlooking some stupid bit of formatting or something. <html><head> <script type="text/javascript"> function ZoomIn() { if document.getElementById('MyIFrame').style.zoom!='100%' { newZoom= parseInt(MyIFrame.style.zoom)+10+'%';
3
1653
by: SM | last post by:
I'm using simpleXML in PHP and i Can't get this small piece of code to work? Need help I have an XML that looks like this: <?xml version="1.0" encoding="utf-8"?> <VIDEO> <item> <title>Letters</title> <videos> <title>a</title>
1
1539
by: Dansmith122 | last post by:
Hi I have been working on the java script for my website and I need help with the out put variables. I need to know how to add more variable for each row in my survey. I am very lost <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />...
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10536
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10304
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9114
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.