I have created a simple Extender Provider and when I drop it onto a
form, it appears in the component tray, but none of the controls it is
supposed to provide a property for show the property in the
PropertyGrid!
Here is the class. The GlassButton is a custom button control that
derives from button and I just do some custom painting. I am sure I
have just omitted something simple, but I cannot see it.
I am using VS 2005.
//This code from BeepProvider.cs
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing.Design;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
[ProvideProperty("BeepWhenClicked", typeof(GlassButton))]
public partial class BeepProvider : Component, IExtenderProvider
{
Dictionary<GlassButton, bool> _beeps;
public BeepProvider()
{
InitializeComponent();
_beeps = new Dictionary<GlassButton, bool>();
}
public BeepProvider(IContainer container)
: this()
{
container.Add(this);
}
bool IExtenderProvider.CanExtend(object extendee)
{
if ((extendee is GlassButton) && !(extendee is BeepProvider))
return true;
else
return false;
}
public bool GetBeepWhenClicked(GlassButton gb)
{
return _beeps[gb];
} //end method GetBeedWhenClicked
public void SetBeepWhenClicked(GlassButton gb, bool value)
{
_beeps[gb] = value;
if (value)
gb.Click += new EventHandler(OnClick);
else
gb.Click -= new EventHandler(OnClick);
}
private void OnClick(object sender, EventArgs e)
{
System.Console.Beep(1000, 50);
}
}
//This code from BeepProvider.Designer.cs
using System.ComponentModel;
using System.Windows.Forms;
[ProvideProperty("BeepProvider", typeof(GlassButton))]
partial class BeepProvider
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
} 1 1751
Chris Dunaway wrote: Here is the class. The GlassButton is a custom button control that derives from button and I just do some custom painting. I am sure I have just omitted something simple, but I cannot see it.
It wasn't very simple or intuitive, but here is my solution:
[ProvideProperty("BeepWhenClicked", typeof(GlassButton))] public partial class BeepProvider : Component, IExtenderProvider
In these lines I can't use my custom control class name, it has to be
Control like this:
[ProvideProperty("BeepWhenClicked", typeof(Control))]
public partial class BeepProvider : Component, IExtenderProvider
{
Dictionary<GlassButton, bool> _beeps;
Next, I can not use a generic dictionary but I have to use a Hashtable
like this:
Hashtable _beeps;
public BeepProvider() { InitializeComponent(); _beeps = new Dictionary<GlassButton, bool>();
use a Hashtable here as well.
_beeps = new Hashtable();
bool IExtenderProvider.CanExtend(object extendee) { if ((extendee is GlassButton) && !(extendee is BeepProvider)) return true; else return false; }
This part is Ok, I can use GlassButton here to restrict what controls
are extended public bool GetBeepWhenClicked(GlassButton gb) public void SetBeepWhenClicked(GlassButton gb, bool value)
These two methods had to be changed to Control rather than GlassButton
What I don't understand is why. Does anyone have any insight?
Thanks,
Chris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: wayne mcfadden |
last post by:
Hi,
I'm stumped. Our text extenders stopped working on one database. I
think that i'm missing something simple here.
The column is enabled...
but when you do an index status
it doesn't know...
|
by: Jeff |
last post by:
I am trying to run the getstart_prep.cmd to enable the SALES_DB
on the "/var/tmp/db2/ese/db2/solaris/db2xml81/reloc/IBM/db2/\$PRODVERS/bin/dxxadm
enable_db SALES_DB" command I get the following...
|
by: Nina via DBMonster.com |
last post by:
Hi,
I am trying to use the AIV extender with DB2 PE v 8.2.
However, when i try to enable database for DB2Video I get the following
error report:
db2ext => enable database for db2video...
|
by: JezB |
last post by:
Could anyone tell me how to implement an extender provider for ASP.NET ? I
have done this successfully for windows forms but all the online
documentation tells us is :
The implementation of an...
|
by: JezB |
last post by:
Could anyone tell me how to implement an extender provider for ASP.NET ? I
have done this successfully for windows forms but all the online
documentation tells us is :
The implementation of an...
|
by: Tim |
last post by:
hi all,
a simple OO related question...
I have some controls. Say, a textbox, a combo and a datepicker.
They all share some properties (tag, size etc).
How should I add another shared...
|
by: Andrew |
last post by:
Hi,
I implemented a simple WMI Provider in C#.
It is a service which expose 10 instances of a simple WMI Class.
The WMI class pnly expose 4 public properties (Value,Min,Max,StdValue) which...
|
by: Brad |
last post by:
To DB2 Personal Developer Edition GIS users:
How do I acquire a spatial extender license key for the DB2 PDE? I
expected to be able to use it right out of the box.
Brad
|
by: bellgodz |
last post by:
Hello,
I have a text box on an .aspx page that an AJAX calendar extender is tied to. When this page is loaded the text box in question is populated with a date from a selected record. I've tried...
|
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
| |