473,799 Members | 2,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1469
On Jul 10, 10:51 am, Rick <rick.delo...@r ogers.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.Reflecti on.Assembly.Get Type(...) 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.Reflecti on.Assembly.Get Type(...) 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.Reflecti on.Assembly.Get Type 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.Assem bly)? 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.Curre ntDomain.GetAss emblies

Greets
Daniel
Jul 11 '07 #3
On Jul 11, 4:30 am, <cami...@commun ity.nospamwrote :
runtime is using System.Reflecti on.Assembly.Get Type(...) 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.Reflecti on.Assembly.Get Type 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.Assem bly)? 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.Curre ntDomain.GetAss emblies

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 projectreferenc e 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...@commun ity.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 projectreferenc e 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.MyEnu m
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
3974
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 them to the wizard, via add-in? I tried to capture it with a macro, but all I can't get out of it is the raise event of the wizard, nothing that happens during the wizard. "
1
3015
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 I want to perform the validation only on the datagrid rows where a check box is checked. Part of the datagrid: <asp:TemplateColumn HeaderText="C #"> <ItemTemplate>
2
3201
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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/creatingcustomcolumns.asp The problem I am having is that the data in the custom datagridcolumn is not saved to viewstate and after postback, the column does not contain data.
1
3600
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 having a couple problems so far. 1. with the way the Paint method works: When I scroll to the right, the custom column gets Drawn on top of the left-most "Selecting" column (the one where the green arrows are displayed). How can I possibly modify...
2
1522
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 having is that whether the checkbox is ticked or not it returns the value "on" to my validator code. This is all using the ideas of DanielHac as at http://www.codeproject.com/aspnet/MultiDependValidator.asp & he suggests extending the checkbox...
0
2156
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 one of my ASP.NET 1.1 web forms. This involves a fairly simple inheritance of the System.Web.UI.WebControls.RadioButtonList class, with some new properties added and the Render sub overridden. When I come to render each radio item, I do the...
3
3185
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 I would like to show a checkboxlist within my formview to represent them. I just have no idea how to bind this collection to a list within the formview? Has anyone got any ideas on this? I don't need the full code, just a pointer in the right...
15
6523
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 accept other controls. The control i drag drop on it becomes the child of my custom control's parent form and not the child of my custom control. Then i added this line "" before my custom control class (i dont know what this line does). Now
5
3753
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 project. The original code for that control was written in VS 2003 for .NET 1.1. I created a Web Project and pulled the VB module into the project. I compared the syntax to the VB template classs that was built and it looked very similar. I then...
0
9688
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
10491
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10268
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
7571
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
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
5467
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...
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
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.