473,407 Members | 2,629 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,407 software developers and data experts.

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

Shashi Sadasivan
1,435 Expert 1GB
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 8789
CyberSoftHari
487 Expert 256MB
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 Expert 1GB
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 Expert 256MB
you have to place the control in windows form to list in property window.
Nov 16 '07 #4
Shashi Sadasivan
1,435 Expert 1GB
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 Expert 256MB
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 Expert 1GB
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 Expert 1GB
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 Expert 256MB
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
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...
18
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...
3
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...
2
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:...
4
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
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...
6
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. ...
14
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...
4
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...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
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,...
0
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...

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.