By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,741 Members | 2,004 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,741 IT Pros & Developers. It's quick & easy.

Win Control and designtime refresh

P: n/a
Hi all

Im currently constructing a Windows control that inherits from RichTextBox,
but I'm having a bit of trouble with updating the control at design time.

The senario is SIMPLIFIED as follows:

My RichTextBox control :

Public Class Crtb
Inherits RichTextBox

private _indentifiers() as Identifier ' An array of Indentifier objects

Public Sub RefreshRtb
' Refreshes the Box acording to the Identifiers
End Sub

Public Overloads Sub AddIndentifier(ByVal characters As String, ByVal
color As System.Drawing.Color)
ReDim Preserve Me._indentifiers(Me._indentifiers.GetUpperBound(0) + 1)
Me._indentifiers(Me._indentifiers.GetUpperBound(0) ) = New
Identifier(characters, color)
End Sub

End Class
An Identifier Class holding a KeyWord as _formatCharacters and a Color to
use in the RTB for this keyword:

< Serializable()> _
Public Class Identifier
Private _formatCharacters As String
Private _color As System.Drawing.Color

Public Property FormatCharacters() As String
......
Public Property Color() As System.Drawing.Color
.....
Public Sub New()
Me._formatCharacters = ""
Me._color = System.Drawing.Color.Blue
End Sub

Public Sub New(formatCharacters As String, color as System.Drawing.Color)
me._formatCharacters = formatCharacters
me._color = color
End Sub

End Class
This is very simplified but should give a picture of the senario.

Now when adding a control to a form I can edit the Identifiers property
array at design time, and so add new Identifiers and e.g. change the color of
the existing ones.

My problem is that I want the RTB control to refresh itself on designtime
when I change e.g. a color property of one of the Identifiers objects in the
array. This can be done by adding an event to the Identifier class and
thereafter adding a handle that calls Refresh for this event each time a new
Identifier is added to The RTB.

This though gives me a big problem since an eventhandler is not able to be
serialized, which meens that the refresh functionallity disappears when I run
the app and return to design mode. As far as I know the control saves it's
state in the resx file, but since the event handlers can't be serialized this
part of the control is lost.

This is a senario that is used in many controls out there, so I hope that
someone is able to tell me how to get this designtime refresh functionallity
in some other way.

Thanks in advance

Allan
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.