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 2 1226
Your color property should look like:
Public Property Color() As System.Drawing.Color
get
set (byval value as color)
_color = value
me.invalidate <---- add this line if you did not do so.
end property
Ahmed
Allan Bredahl wrote: 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
"Ahmed" <ah*******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com... Your color property should look like:
Public Property Color() As System.Drawing.Color get
set (byval value as color) _color = value me.invalidate <---- add this line if you did not do so. end property
Ahmed
Thanks Ahmed, but that just won't do the trick since my color property is
not on the Control itself, but on an "Identifier" object contained in an
Array on the control
Allan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rahail |
last post by:
Hello,
I have a question, can someone help me please?
What are the differences between a runtime and a designtime component?
Is runtime component only good for running with the .exe and not...
|
by: Weinand Daniel |
last post by:
i'd like to monitor changes of the "Control.Name" porperty during
designtime.
if the user changes the name in designer my event musst fire.
i have created a own button control. with an event...
|
by: Jensen Bredal |
last post by:
Hello,
I need to display self refreshing information on a web page written with
asp.net. I would image that the info would be displayed either as part of a
user control or a web control.
How can...
|
by: Allan Bredahl |
last post by:
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...
|
by: Allan Bredahl |
last post by:
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...
|
by: Mike |
last post by:
Hi.
I want to refresh the design time control html when a property is changed.
I've used NotifyParent(true) attribute but doesn't work. My control inherit
from System.Web.UI.Control. How can i...
|
by: Yuk Tang |
last post by:
Another step on the road to enlightenment, aka producing a UI. I've
added a webbrowser control to a form, and I want it to fill the space
of the form. Playing around with docking, left, top,...
|
by: rotsj |
last post by:
Hello,
I would like to make my own dropdownlist and add a collection as a generic
List.
When I enter items @ designtime, @ runtime they are gone.
Can anyone tell me please what the problem...
|
by: Johnny Jörgensen |
last post by:
I would like to be able to tell whether my component code is executed when I
instanciate a control in runtime or in designtime.
Can anybody give me a clua as to how you can do that?
Cheers,...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
| |