473,383 Members | 1,855 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,383 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 1294
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,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.