Help! Font property read only in VS.NET?

  • Thread starter Thread starter Nicholas Paldino [.NET/C# MVP]
  • Start date Start date
N

Nicholas Paldino [.NET/C# MVP]

Amith,

Technically, the font property is both read and write. Its the
properties on the IFontDisp interface that are not read and write. Can you
show what the declaration of the IFontDisp interface is (it has to be in an
interop assembly of some kind). Perhaps the definition is incorrect.

Hope this helps.
 
Hi,

I am using an ActiveX created using delphi. It has a font property exposed.
The font property is of type IFontDisp in the server(delphi). The font
properties like Size, Bold, Underline etc has both 'Set' and 'Get' methods
when using the activex in a VS6 app.

But when using the activeX in a VS.NET app, the font properties are read
only. The only way that i can set the font properties is by:

MyActiveX.Font = new Font("Arial", 10, FontStyle.Bold)

Subsequently if i need to turn off Bold, i need to again make use of font
constructor like:

MyActiveX.Font = new Font("Arial", 10, FontStyle.Regular)

If the font properties are writable, i can set its properties by:

MyActiveX.Font.Bold = True
MyActiveX.Font.Italics = True

How can i acheive this? i.e. the font property that is exposed from my
activex server (written in delphi) should be both read and write in my
VS.NET client.

Please help!

Thanks in advance.
Amith.
 
I am trying a technique that I got from another website. (It supposedly
referenced this thread, but I can't see the posts.)

The technique to set the bold property works like this:
TreeNode newNode = new TreeNode("Nodename");

Font oldFont = TreeView.Nodes[0].NodeFont; // <---Error occurs here

newNode.NodeFont = new Font(oldFont, System.Drawing.FontStyle.Bold);

oldFont.Dispose();

But it doesn't work because TreeView.Nodes[0].NodeFont always throws an
"Object reference not set to an instance of an object." error. In
QuickWatch the NodeFont shows an <undefined error>.

What's the secret handshake to get this to work?

Thanks in advance

Nicholas Paldino said:
Amith,

Technically, the font property is both read and write. Its the
properties on the IFontDisp interface that are not read and write. Can you
show what the declaration of the IFontDisp interface is (it has to be in an
interop assembly of some kind). Perhaps the definition is incorrect.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Amith said:
Hi,

I am using an ActiveX created using delphi. It has a font property exposed.
The font property is of type IFontDisp in the server(delphi). The font
properties like Size, Bold, Underline etc has both 'Set' and 'Get' methods
when using the activex in a VS6 app.

But when using the activeX in a VS.NET app, the font properties are read
only. The only way that i can set the font properties is by:

MyActiveX.Font = new Font("Arial", 10, FontStyle.Bold)

Subsequently if i need to turn off Bold, i need to again make use of font
constructor like:

MyActiveX.Font = new Font("Arial", 10, FontStyle.Regular)

If the font properties are writable, i can set its properties by:

MyActiveX.Font.Bold = True
MyActiveX.Font.Italics = True

How can i acheive this? i.e. the font property that is exposed from my
activex server (written in delphi) should be both read and write in my
VS.NET client.

Please help!

Thanks in advance.
Amith.
 
Back
Top