Re: NotSupportException caused by DrawString
From: Serg Kuryata [MS] (sergeyk_at_online.microsoft.com)
Date: 07/16/04
- Next message: Serg Kuryata [MS]: "RE: Windows.Forms Issue (compact framework)"
- Previous message: Serg Kuryata [MS]: "Re: Explained: Toolbar buttons and WM 2003SE"
- In reply to: Tim Wilson: "Re: NotSupportException caused by DrawString"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 16 Jul 2004 22:10:20 GMT
Yes, Tim is correct. The Font property is not supported by the PictureBox
control.
Thank you,
Sergiy.
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM>
| References: <61F61207-A9CB-4E7B-B12C-C4E82F425B64@microsoft.com>
<OQjprJLZEHA.1152@TK2MSFTNGP09.phx.gbl>
<A93A3D55-2C57-4442-8B20-4B80251A26EF@microsoft.com>
| Subject: Re: NotSupportException caused by DrawString
| Date: Thu, 8 Jul 2004 08:25:37 -0400
| Lines: 83
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
| Message-ID: <#Yv9eaOZEHA.716@TK2MSFTNGP11.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host:
cpe00045af65bf7-cm014210012048.cpe.net.cable.rogers.com 24.103.185.244
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGXS01.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP0
8.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:56916
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| The actual issue is with getting and setting the Font property. It looks
| like it's not supported for the PictureBox. If you create your own
property
| to store the font it should work. Add the code below to your PicBody
class.
|
| Private _Font As Font = New Font("Tahoma", 8, FontStyle.Regular)
|
| Public Overrides Property Font() As System.Drawing.Font
| Get
| Return _Font
| End Get
| Set(ByVal Value As System.Drawing.Font)
| _Font = Value
| End Set
| End Property
|
| --
| Tim Wilson
| .Net Compact Framework MVP
|
| "Kempton" <Kempton@discussions.microsoft.com> wrote in message
| news:A93A3D55-2C57-4442-8B20-4B80251A26EF@microsoft.com...
| > Public Class PicBody
| > Inherits System.Windows.Forms.PictureBox
| >
| > Private xArr() As Integer = {-1, -1, -1, -1, -1, -1} 'the
| x-coordinates of all nodes
| > Private yArr() As Integer = {-1, -1, -1, -1, -1, -1} 'the
| y-coordinates of all nodes
| >
| >
| > Protected Overrides Sub onPaint(ByVal e As
| System.Windows.Forms.PaintEventArgs)
| > e.Graphics.DrawImage(Me.Image, 0, 0) 'show the body
picture
| > Dim b As New SolidBrush(Color.Red)
| >
| > Dim i As Integer
| > For i = 0 To xArr.Length - 1
| > If xArr(i) >= 0 And yArr(i) >= 0 Then
| > e.Graphics.FillEllipse(b, xArr(i), yArr(i), 5, 5)
| > Dim s As String
| > If i = 0 Then
| > s = "Primary"
| > Else
| > s = "Node " & i.ToString
| > End If
| > 'e.Graphics.DrawString(s, Font, b, (xArr(i) + 10),
| yArr(i))
| > End If
| > Next
| >
| > b.Dispose()
| > End Sub
| >
| >
| > Public Sub setNode(ByVal nodeNum As Integer, ByVal x As Integer,
ByVal
| y As Integer)
| > If nodeNum < xArr.Length Then
| > xArr(nodeNum) = x
| > yArr(nodeNum) = y
| > End If
| > End Sub
| > End Class
| >
| > "Tim Wilson" wrote:
| >
| > > Can you post the complete code for your OnPaint method?
| > >
| > > --
| > > Tim Wilson
| > > ..Net Compact Framework MVP
| > >
| > > "Kempton" <Kempton@discussions.microsoft.com> wrote in message
| > > news:61F61207-A9CB-4E7B-B12C-C4E82F425B64@microsoft.com...
| > > > I create a custom control which inherits Picturebox. the
| > > e.Graphics.DrawString in the OnPaint method causes a
| NotSupportedException.
| > > >
| > > > Could anyone help?
| > >
| > >
| > >
|
|
|
- Next message: Serg Kuryata [MS]: "RE: Windows.Forms Issue (compact framework)"
- Previous message: Serg Kuryata [MS]: "Re: Explained: Toolbar buttons and WM 2003SE"
- In reply to: Tim Wilson: "Re: NotSupportException caused by DrawString"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|