473,396 Members | 1,929 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,396 software developers and data experts.

custom property for checkbox

Hi group,

I'm trying to inherit from the windows checkbox control. This is no
problem. My goal is to add a property that is based on an enum. When I
have an enum declared within the class, it works correctly, however,
my enum is declared in a referenced assembly. The form cannot load the
enum from the referenced assembly, it indicates that it can't load the
type.

using VB, VS2005.

Any thoughts on this one? I would like to not have to duplicate my
enum in this class.

Thanks,

Rick.

Jul 10 '07 #1
6 1450
On Jul 10, 10:51 am, Rick <rick.delo...@rogers.comwrote:
Hi group,

I'm trying to inherit from the windows checkbox control. This is no
problem. My goal is to add a property that is based on an enum. When I
have an enum declared within the class, it works correctly, however,
my enum is declared in a referenced assembly. The form cannot load the
enum from the referenced assembly, it indicates that it can't load the
type.

using VB, VS2005.

Any thoughts on this one? I would like to not have to duplicate my
enum in this class.

Thanks,

Rick.
Further investigation shows that this is by design, I guess...the
runtime is using System.Reflection.Assembly.GetType(...) to find the
type information of my enum...this method is only looking in the
currently executing assembly, which means it will never look in my
referenced assembly. This is a poor design, I hope that someone has an
indication as to how to get around this...

TIA. Rick.

Jul 10 '07 #2
runtime is using System.Reflection.Assembly.GetType(...) to find the
type information of my enum...this method is only looking in the
currently executing assembly, which means it will never look in my
referenced assembly. This is a poor design, I hope that someone has an
indication as to how to get around this...
Hi Rick!

You are right. The System.Reflection.Assembly.GetType method looks only in
the executing Assembly. You are using a static (shared) method from the
Assembly class. Of course the executing Assembly will handle this request
(who else?). This is neither a poor design, nor do I see any other way.

Are you able to get the Assemblyobject (the referenced Assembly), containing
the enum (If you have any object o, you can use o.Gettype.Assembly)? Then
you can use the gettype method from this assemblyobject. If you do not have
this reference, you can enumerate through all referenced assemblies by using
AppDomain.CurrentDomain.GetAssemblies

Greets
Daniel
Jul 11 '07 #3
On Jul 11, 4:30 am, <cami...@community.nospamwrote:
runtime is using System.Reflection.Assembly.GetType(...) to find the
type information of my enum...this method is only looking in the
currently executing assembly, which means it will never look in my
referenced assembly. This is a poor design, I hope that someone has an
indication as to how to get around this...

Hi Rick!

You are right. The System.Reflection.Assembly.GetType method looks only in
the executing Assembly. You are using a static (shared) method from the
Assembly class. Of course the executing Assembly will handle this request
(who else?). This is neither a poor design, nor do I see any other way.

Are you able to get the Assemblyobject (the referenced Assembly), containing
the enum (If you have any object o, you can use o.Gettype.Assembly)? Then
you can use the gettype method from this assemblyobject. If you do not have
this reference, you can enumerate through all referenced assemblies by using
AppDomain.CurrentDomain.GetAssemblies

Greets
Daniel
Hi Daniel,

Thanks for your replay. I should clarify a few things. First, the
issue is only at design time. This is a custom property for a custom
inherited checkbox control where the datatype of the property is that
of an enum which is in a referenced assembly. The designer cannot load
the enum from a referenced assembly at design time. The result is a
design time form that is completely unusable. So, I should also
clarify further that what I meant to say when I said executing
assembly, I meant to say the assembly that contains the control. At
runtime, it seems to resolve the enum correctly. But, this really
needs to work at design time to be at all useful.

So far, the only workaround to this is to duplicate the enum within
the control or control's assembly, or to move the control into a
business assembly. Neither solution is desirable though the former is
teh most managable for my checkbox problem.

So far in my investigations, I maintain that this as either an
oversight by the dev team, or a realized limitation that is by design.

Rick.

Jul 12 '07 #4
Hi Rick
of an enum which is in a referenced assembly. The designer cannot load
the enum from a referenced assembly at design time. The result is a
design time form that is completely unusable. So, I should also
clarify further that what I meant to say when I said executing
I was not able to reproduce this. I created a new Project (a classlibary),
and added nothing else than an public enum. I added a second project (a
windows forms project) and added a reference to the first project. In the
winformsapp I added a new class, inherits from checkbox and added a public
property with the type of the external enum. After building the projectmap,
i added the new checkbox to a form and the designer shows my checkbox very
well, and I was able to modifie the testproperty in der propertygrid (and
the values of the enum are shown in the combobox).
Just to be 100% sure, I deleted the projectreference and set a new one,
directly to the dll ... also no problem.

Are you able to post a few lines of code, showing the problem?

greets

Daniel
Jul 12 '07 #5
On Jul 12, 1:30 am, "Daniel Marohn" <cami...@community.nospamwrote:
Hi Rick
of an enum which is in a referenced assembly. The designer cannot load
the enum from a referenced assembly at design time. The result is a
design time form that is completely unusable. So, I should also
clarify further that what I meant to say when I said executing

I was not able to reproduce this. I created a new Project (a classlibary),
and added nothing else than an public enum. I added a second project (a
windows forms project) and added a reference to the first project. In the
winformsapp I added a new class, inherits from checkbox and added a public
property with the type of the external enum. After building the projectmap,
i added the new checkbox to a form and the designer shows my checkbox very
well, and I was able to modifie the testproperty in der propertygrid (and
the values of the enum are shown in the combobox).
Just to be 100% sure, I deleted the projectreference and set a new one,
directly to the dll ... also no problem.

Are you able to post a few lines of code, showing the problem?

greets

Daniel
Hi,

The code is very simple. I am doing exactly what you did.

In assembly one:
public enum MyEnum
Yes
No
End enum

In winform project which references assembly one:
public class myCheckBox
inherits checkbox

public property Bla as Assembly1.MyEnum
get ...
set ..
end property

when dragging the checkbox onto the form, it works. But closing the
form and re-opening it in the design seems to be where the wheels fall
off for me. If this works for you, I will dig deeper. I also tried a
test application and reproduced it. I will try another.

Thanks for you time on checking into this.

Rick.

Jul 12 '07 #6
Hi Rick
when dragging the checkbox onto the form, it works. But closing the
form and re-opening it in the design seems to be where the wheels fall
off for me. If this works for you, I will dig deeper. I also tried a
After opening and closing the designer 20 times, I think it's working in my
side. No error, warning or other kind of problem. The checkbox behaves
exactly as it should and the designer shows form and checkbox correctly.

If I had to guess, I would say this is any kind of VisualStudio problem; If
you like I can send you my solutionfolder, so you can check it against your
enviroment.

btw: do you use vista (I had/have to fight against stupid designerprobs,
using vista)? ...

greets
Daniel

Jul 12 '07 #7

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

Similar topics

1
by: The_Rave | last post by:
Hi everyone, I'm trying to add my own template columns to the property builder of ..NET. E.g. a checkbox column, or an image column. But I can't find the sources of the wizard, or a way to add...
1
by: Stephan Bour | last post by:
Hi, I need to validate a text box in a datagrid nested inside a datalist. All I need is to validate that any text is entered in the textbox. However, a requiredfieldvalidator would not do because...
2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
1
by: nate axtell | last post by:
In VB .Net I made a custom CheckBox column style (for the Datagrid control) that maps to two DataTable columns , one it uses for the Checked status and the other it uses for the Enabled status. I am...
2
by: Martin | last post by:
I am writing a custom validator by extending CustomValidator in order to validate three fields as follows: If checkbox true then textboxA and textboxB must have data in. The problem I am...
0
by: webmaster | last post by:
Hi all, I'm tearing my hair out with this one. I have successfully implemented by own RadioButtonList in order to provide additional functionality and a DIV rather than TABLE-based layout in...
3
by: cannontrodder | last post by:
I am displaying names and other details of my users in a Formview control by binding my custom business object to it. My custom object also has a property that is a collection of boolean values and...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
5
by: John Kotuby | last post by:
Hi all, This is my first time trying to creaet and use a custome Web Control in a Web Site project in ASP.NET 2.0 with VS 2005 and VB. I created the control in a separate Web Control Library...
0
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
0
BarryA
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...
1
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...
0
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...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...

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.