473,320 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

change a property does not update custom control

Hi,

I have some issue with my custom control.
When i change my property "GridLine.Color" my custom control should
redraw its border with the specified color. However, nothing happens.

therefore based on an example from a book i implemented an eventhandler
and tried to manage it like that... but still nothing.

Here is my code example :

public class CGridLine
{
public event EventHandler PropertyChanged;
private Color m_GridLinesColor;

public Color Color
{
get
{
return this.m_GridLinesColor;
}
set
{
this.m_GridLinesColor = value;
this.OnPropertyChanged(EventArgs.Empty);
}
}
....
private void OnPropertyChanged(EventArgs e)
{
if (PropertyChanged != null)
{
PropertyChanged(this, e);
}
}
}

here is my custom control code :
....
public CGridLine GridLines
{
get
{
return this.m_GridLines;
}
set
{
this.m_GridLines = value;
if (GridLinePropertyChanged != null)
{
this.m_GridLines.PropertyChanged -= this.GridLinePropertyChanged;
}
this.GridLinePropertyChanged = new
EventHandler(GridLines.PropertyChanged);
this.m_GridLines.PropertyChanged += this.GridLinePropertyChanged;
this.Invalidate();
}
}
....
Could someone give me an example how to update during design time, the
custom control using eventhandler ?

thanks a lot,

Al.
Feb 16 '07 #1
1 2323
First: for default binding notification events to work, the name is
important: yours should be ColorChanged, not PropertyChanged. This is
a good approach to stick to, as it is a: expected, and b: necessary
for PropertyDescriptor.{Add|Remove}ValueChanged to work correctly
using the default reflection model.

However! There is nothing in the sample provided that would cause it
to redraw when the Color changes; you need to cause invalidate etc -
unless that is hidden in GridLinePropertyChanged (which you haven't
shown us).

Marc
Feb 16 '07 #2

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

Similar topics

13
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
4
by: Scott | last post by:
How can I use the value in a combobox in a custom menu as the LinkMaster property to a subform on a form? Thanks! Scott
6
by: Aaron Smith | last post by:
Ok. I have a dataset that has multiple tables in it. In one of the child tables, I have a column that I added to the DataSet (Not in the DataSource). This column does not need to be stored in the...
0
by: Mythran | last post by:
In a custom web control, I have 2 properties that are affected when 1 changes. When Property1 changes, I need Property2 to be updated as well. When Property2 changes, Property1 does NOT need to...
4
by: Bob | last post by:
Hi, Is it possible to change the forecolor of a disabled text control. I have a RichText Box that I don't want the user to edit but the Grey on Grey default is hard to read. Is there a way of...
1
by: --== Alain ==-- | last post by:
Hi, I have a huge problem... My property does not appear in the "propertyGrid" of "test Container", when i test my custom control. Here is the custom control code : namespace...
1
by: --== Alain ==-- | last post by:
Hi, I have a collection property in my custom control like this one : public ColumnCollection Columns
1
by: savajx1 | last post by:
I need to dynamically create a set of bound fields contained in a GridView control. I also have a single static CommandField that I can declare in the Columns <tagof the GridView control. I have...
3
by: R.A.F. | last post by:
Hi, I have a custom control in which i have a property based on CollectionBase class. like the following one : //------- XGrid.cs file --------------// public ColumnsCollection Columns {
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.