473,657 Members | 2,426 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Win control refreshing at designtime

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._indentifier s(Me._indentifi ers.GetUpperBou nd(0) + 1)
Me._indentifier s(Me._indentifi ers.GetUpperBou nd(0)) = New
Identifier(char acters, color)
End Sub

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

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

Public Property FormatCharacter s() As String
......
Public Property Color() As System.Drawing. Color
.....
Public Sub New()
Me._formatChara cters = ""
Me._color = System.Drawing. Color.Blue
End Sub

Public Sub New(formatChara cters As String, color as System.Drawing. Color)
me._formatChara cters = formatCharacter s
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
2 1237
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._indentifier s(Me._indentifi ers.GetUpperBou nd(0) + 1) Me._indentifier s(Me._indentifi ers.GetUpperBou nd(0)) = New
Identifier(char acters, color)
End Sub

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

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

Public Property FormatCharacter s() As String
......
Public Property Color() As System.Drawing. Color
.....
Public Sub New()
Me._formatChara cters = ""
Me._color = System.Drawing. Color.Blue
End Sub

Public Sub New(formatChara cters As String, color as System.Drawing. Color) me._formatChara cters = formatCharacter s
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 #2

"Ahmed" <ah*******@gmai l.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.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
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1792
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 during development environment using Visual Basic 6 (For example, an error pops out saying License is not found - I am using 3rd party components.)?
4
2981
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 NameChange. during runtime it works fine. if the name of the control has changed the event is fireing. (for example: designtime name of the button is btnOk, on a second button
5
3475
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 this be done? The information will come from a database and the displaying should loop throug a table in the database. Many thank in advance JB
0
1017
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 follows: My RichTextBox control : Public Class Crtb
0
1082
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 follows: My RichTextBox control : Public Class Crtb
0
1040
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 refresh DesignTime Control html? Thanks! :)
10
3251
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, width, height resolutely refuses to do this, as it remains docked top-left at around 100,100 within the form, with a size of approx 300,250. How do I fill the winform with the wb control? Reading further, it looks like another argument for...
2
1695
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 is? This is my code:
2
1701
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, Johnny J.
0
8402
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
8315
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
8734
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...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7341
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
5633
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
4164
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
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.