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

Custom Structures in a Custom Control?

PR
Hello,

I'm creating a Windows control that includes a few textboxes. In the form
designer, I want there to be one property that drops down into a few
sub-values for the different text boxes, somewhat akin to how Location and
Size usually work for many standard controls.

(There may be more appropriate ways to do this, but I'm kind of doing it as
a self-tutorial.)

I've tried creating a Property which returns a Structure declared within the
custom control class, but that doesn't seem to work. The form designer
simply represents the Value property in grayed-out text reading
"ctlPhoneNumberTextBox.PhoneNumberTextBox+PhoneNum ber". Any ideas?

Here's a code snippet, if it helps:

***
Public Class PhoneNumberTextBox
Inherits System.Windows.Forms.UserControl

Private areaCodeStr As String
Private exchangeStr As String
Private suffixStr As String
Private extensionStr As String

Public Structure PhoneNumber
Public AreaCode As String
Public Exchange As String
Public Suffix As String
Public Extension As String
End Structure

Property Value() As PhoneNumber
Get
Dim returnPhoneNumber As PhoneNumber
returnPhoneNumber.AreaCode = areaCodeStr
returnPhoneNumber.Exchange = exchangeStr
returnPhoneNumber.Suffix = suffixStr
returnPhoneNumber.Extension = extensionStr
Return returnPhoneNumber
End Get
Set(ByVal Value As PhoneNumber)
areaCodeStr = Value.AreaCode
exchangeStr = Value.Exchange
suffixStr = Value.Suffix
extensionStr = Value.Extension
End Set
End Property

Mar 29 '07 #1
2 1298
PR wrote:
I've tried creating a Property which returns a Structure declared within
the custom control class, but that doesn't seem to work. The form
designer simply represents the Value property in grayed-out text reading
"ctlPhoneNumberTextBox.PhoneNumberTextBox+PhoneNum ber". Any ideas?
It's doing the best that it can; it's listing your property and
displaying the only value it can get for it, that returned by calling
ToString() on the current value.

You have to build another class that does the translation, back and
forth, between your Property and the Designer's Property Window, then
link it to your new Control using a TypeConverter Attribute.

HTH,
Phill W.
Mar 30 '07 #2
>I've tried creating a Property which returns a Structure declared within
>the custom control class, but that doesn't seem to work. The form
designer simply represents the Value property in grayed-out text reading
"ctlPhoneNumberTextBox.PhoneNumberTextBox+PhoneNu mber". Any ideas?

It's doing the best that it can; it's listing your property and displaying
the only value it can get for it, that returned by calling ToString() on
the current value.

You have to build another class that does the translation, back and forth,
between your Property and the Designer's Property Window, then link it to
your new Control using a TypeConverter Attribute.
Wow. Sounds hard. Thanks for your answer, though. I may just forego
this'un... I can live with the Form Designer not understanding me...

Apr 1 '07 #3

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

Similar topics

4
by: drewnoakes | last post by:
Hi, I'm developing an application server to which clients will connect over the network. This server has a variety of entry points, and remoting seems well suited for those clients written in...
33
by: Peter Seaman | last post by:
I understand that structures are value types and arrays and classes are reference types. But what about arrays as members of structures i.e. as in C struct x { int n; int a; }
5
by: Brian Keating EI9FXB | last post by:
Hello there, Wonder can anyone point me in the correct direction? I would like to change the standard list view control so that i can have alternated rows in a different color, i.e. white grey...
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
8
by: Techno_Dex | last post by:
Has anyone come up with a slick way to make Custom Serializable Objects to behave like DataSets when using WebServices? What I'm looking for is some way to force the WSDL generated code to create...
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...
0
by: Peter | last post by:
Hello, I'm creating a Windows control that includes a few textboxes. In the form designer, I want there to be one property that drops down into a few sub-values for the different text boxes,...
4
by: jehugaleahsa | last post by:
Hello: When developing data structures for C#, there is an obvious performance hit when utilizing primitive types. For instance, a recent hash table implementation I wrote works exceedingly fast...
1
by: jehugaleahsa | last post by:
Hello: I am experiencing performance related issues when my custom data structures work with value types. I use generics to prevent boxing wherever I can. For instance, I use IEqualityComparer,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.