473,763 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[C#, windows Forms Control Library] create a custom property with its own drop down l

Shashi Sadasivan
1,435 Recognized Expert Top Contributor
I am creating a clock control
something that will display the time (unfortunately i could not see that in the control list)

however, i created a property which is of string type, representing the format in which the time should be shown.

I want the user to be able to choose a format from a drop down list in the property window.

how do i go about doing this?

PS. Seems to me that it would sit somewhere in the attribute for that property, im I have not been able to grasp that part. Hope this starts to build my knowledge!
Nov 16 '07 #1
8 8806
CyberSoftHari
487 Recognized Expert Contributor
You can create your own clock design in UserControl.cs[Desigen] and write properties in UserControl.cs.
BTW you never mention the version of C# front-end.
Nov 16 '07 #2
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
You can create your own clock design in UserControl.cs[Desigen] and write properties in UserControl.cs.
BTW you never mention the version of C# front-end.
Thanks for pointing that out, its the 2.0 version of the framework i am using.

The control just has a text box which displays the time (not a graphical one)
I do know how to create properties for it to appear in the properties window,
however I want a way in which the user can only select a few defined ways of selecting which format they want it in.
So a drop down list in the properties window (something similar to ImeMode Property which has a list of selections the user can select) is what i am chasing !
Nov 16 '07 #3
CyberSoftHari
487 Recognized Expert Contributor
you have to place the control in windows form to list in property window.
Nov 16 '07 #4
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
you have to place the control in windows form to list in property window.
[:-|]
Yes I think that is what usually happens, I add the dll to my toolbox in a windows form project and then place it on the form,
my question is a step before that happens, if i have a string property, i want the user to select only 5 types of values.
this is not a user control. Its a custom control (well its almost the same)
Nov 16 '07 #5
CyberSoftHari
487 Recognized Expert Contributor
Create enumerate data type variable with that 5 or 6 list of value and set it to the property.
Nov 16 '07 #6
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
Create enumerate data type variable with that 5 or 6 list of value and set it to the property.
Okay, If enumeration is the way to do it (which means i will have to convert the integers back to a string) how do you go about "setting" it to the property?

will the compiler sense its location and populate it by itself or do i have to set any attributes for that?
Nov 16 '07 #7
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
Should have tried before posting that.
Well, I was excited to try it.
Yes it did work. :)
So the conclusion I reached is that if you have a property (string type) whise values has to be predefined , you will have to create another property which excepts an enum value and then convert that enum value to a string value as required. You cannot bind a lit of string to the property.

Thanks for your suggestion. Appreciate it a lot
Nov 16 '07 #8
CyberSoftHari
487 Recognized Expert Contributor
yes enumeration will display the drop down list in property.
Nov 16 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1561
by: ttupper | last post by:
I have made a custom control that has a property that is a custom component. When I put the custom control on a form in the designer, the propery is listed in the Properties window with a default value of (none). I then put the custom component on the form and it goes in the Component tray like it is supposed to. I then drop down the property on the custom control and the only value ni the list is (none).
18
3070
by: jrhoads23 | last post by:
Hello, I am trying to find a way to tell if an .NET windows forms Button (System.Windows.Forms.Button) is "depressed" (pushed down). For my application, I can not use a check box control set to button style, I must use a System.Windows.Forms.Button. I can not find a way to tell when it is momentaraly pressed. I tried calling the API SendMessage with the button handle and BM_GETSTATE to get the state of the button. This will only return...
3
57001
by: Jeremy S. | last post by:
On my dev machine (XP/Pro with VS.NET 2003) I have been developing a Windows Service and installing it on the local machine by opening the Visual Studio Command Prompt and then executing . Now I want to test this service on a Windows Server 2003 box that doesn't have the Visual Studio Command prompt. How do I go about installing the service on the Windows Server 2003 box? Thanks!
2
1283
by: Jay Douglas | last post by:
I have various different web user controls through out my web application. I would like to view the properties/fields for these user controls in the designer property window .... For instance: public bool HasMenu { get { return hasMenu; }
4
6724
by: rajendra | last post by:
how to extend existing windows forms control like if i want to add new add method to combo box ,how to go abt. it? can anyone help me abt. this
2
14021
by: JohnR | last post by:
Let's say I have an MDI parent form with a textbox. If I create an MDI child form and, at runtime, move the MDI child window over the textbox on the MDI parent, the textbox appears in front of the MDI child window. How can I make the MDI child window appear in front of any controls that may be on the MDI parent? thanks, John
6
4367
by: Bob The Builder | last post by:
I have a custom-built datagrid for windows forms. I overrode the scrollbars in it because I wanted to draw my own (basically, they're skinned). As a result, I handle all scroll events and calls. I also have a row-selector column as the first column, and that needs to stay visible. Think Excel. However, if a user clicks a cell that is all the way to the right and goes off the grid a bit, then the entire grid shifts, including my...
14
3366
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought I'll make the inactive forms invisible but this is creating a memory corruption problem when user close the form2 or form3 and not the formMain. My main form has a Next button which makes the main form invisible and starts a new form which I'll...
4
6666
by: Jerad Rose | last post by:
I'm baffled by this -- is there not a typed object used for ComboBox Items? Best I can tell, all of the methods for ComboBox that accept an Item are of type Object. Why in the world is a common/standard .NET control accepting an Object as a parameter type? In Web Forms, there is a ListItem object that can be passed in to add/retrieve objects from a DropDownItems collection. I searched Google groups, and all the solutions I'm finding...
0
10149
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
10003
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...
0
9828
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8825
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
6643
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
5271
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
5410
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3529
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2797
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.