Trying to specify a single public property on my user control to hold three
different images. I figure out how to do this and Google searches are not
helping. (I probably am not searching on the right terms.)
My sample below is using an array of images, but I cannot specify more than
one parameter in the SET statement. I'm not sure how I'd change this to use
a collection of images.
....
Private iImages(2) as image 'Holds three images
....
'Set/Return image for particular state
Public Property image(ByVal index As Integer) As image
Get
Return iImages(index)
End Get
Set(ByVal index as Integer, ByVal Value As image) '<---Doesn't work. How
do I specify an index
iImages(index) = Value
If iIndex = index Then 'If changing image for currently displayed image,
apply it to display
picImage.Image = Value
End If
End Set
End Property 15 5879
Hi Noozer,
I think you have to make 2 properties,
one to set your index and one for the image you want to have returned
Or some functions
I would choose for the 2 properties and then the image is readonly
I hope this helps?
Cor Trying to specify a single public property on my user control to hold
three different images. I figure out how to do this and Google searches are not helping. (I probably am not searching on the right terms.)
My sample below is using an array of images, but I cannot specify more
than one parameter in the SET statement. I'm not sure how I'd change this to
use a collection of images.
... Private iImages(2) as image 'Holds three images ...
'Set/Return image for particular state Public Property image(ByVal index As Integer) As image Get Return iImages(index) End Get Set(ByVal index as Integer, ByVal Value As image) '<---Doesn't work. How do I specify an index iImages(index) = Value If iIndex = index Then 'If changing image for currently displayed
image, apply it to display picImage.Image = Value End If End Set End Property
There has to be a way to make it appear as a collection like VB.Net's built
in controls do it.
"Cor" <no*@non.com> wrote in message
news:Op******** ******@TK2MSFTN GP09.phx.gbl... Hi Noozer,
I think you have to make 2 properties, one to set your index and one for the image you want to have returned Or some functions
I would choose for the 2 properties and then the image is readonly
I hope this helps?
Cor
Trying to specify a single public property on my user control to hold three different images. I figure out how to do this and Google searches are
not helping. (I probably am not searching on the right terms.)
My sample below is using an array of images, but I cannot specify more than one parameter in the SET statement. I'm not sure how I'd change this to use a collection of images.
... Private iImages(2) as image 'Holds three images ...
'Set/Return image for particular state Public Property image(ByVal index As Integer) As image Get Return iImages(index) End Get Set(ByVal index as Integer, ByVal Value As image) '<---Doesn't work.
How do I specify an index iImages(index) = Value If iIndex = index Then 'If changing image for currently displayed image, apply it to display picImage.Image = Value End If End Set End Property
FWIW... I sortof have the functionality by defining my property as an
imagelist.
Still not what I want though as I need a collection of individual images
that could be different sizes.
I know I'm missing something very basic here and I just can't nail it down!
Talk about frustrating!
: )
"Noozer" <po********@127 .0.0.1> wrote in message
news:GUxIb.8770 73$pl3.338306@p d7tw3no... There has to be a way to make it appear as a collection like VB.Net's
built in controls do it.
"Cor" <no*@non.com> wrote in message news:Op******** ******@TK2MSFTN GP09.phx.gbl... Hi Noozer,
I think you have to make 2 properties, one to set your index and one for the image you want to have
returned Or some functions
I would choose for the 2 properties and then the image is readonly
I hope this helps?
Cor
Trying to specify a single public property on my user control to hold three different images. I figure out how to do this and Google searches are not helping. (I probably am not searching on the right terms.)
My sample below is using an array of images, but I cannot specify more than one parameter in the SET statement. I'm not sure how I'd change this
to use a collection of images.
... Private iImages(2) as image 'Holds three images ...
'Set/Return image for particular state Public Property image(ByVal index As Integer) As image Get Return iImages(index) End Get Set(ByVal index as Integer, ByVal Value As image) '<---Doesn't work. How do I specify an index iImages(index) = Value If iIndex = index Then 'If changing image for currently displayed
image, apply it to display picImage.Image = Value End If End Set End Property
Hi Noozer,
Yes I think you mis something basic, I tried to tell you
I did type it here (Roughly not tested, see it as pseudo, altough I think it
is complete)
2 samples as propertys and as function
I hope this was what you where looking for?
Cor
\\\
Public Class Noozer
Private Shared iImages(2) as image 'Holds three images
Private Shared pIndex as integer ' holds the index
'Set/Return image for particular state
Public shared Read Only Property myImage As image
Get
Return iImages(pImage)
End Get
End Property
Public shared Property i as integer
Get
Return pIndex
End Get
Set (byVal Value as integer)
pIndex = Value
End Set
End Property
'to set and get this this
Noozer.index = 1
myImage = Noozer.MyImage
'As a function
Public shared function MyImage (byval i as integer) as image
return iImages(i)
End function
'to get this
myImage = Noozer.myimage( 1)
/// Still not what I want though as I need a collection of individual images that could be different sizes.
I know I'm missing something very basic here and I just can't nail it
down! Talk about frustrating!
: )
* "Noozer" <po********@127 .0.0.1> scripsit: Trying to specify a single public property on my user control to hold three different images. I figure out how to do this and Google searches are not helping. (I probably am not searching on the right terms.)
My sample below is using an array of images, but I cannot specify more than one parameter in the SET statement. I'm not sure how I'd change this to use a collection of images.
... Private iImages(2) as image 'Holds three images ...
'Set/Return image for particular state Public Property image(ByVal index As Integer) As image Get Return iImages(index) End Get Set(ByVal index as Integer, ByVal Value As image) '<---Doesn't work. How
Just skip the index parameter above.
do I specify an index iImages(index) = Value If iIndex = index Then 'If changing image for currently displayed image, apply it to display picImage.Image = Value End If End Set End Property
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
And this will show up as a Collection in the Properties page of my
control???
"Cor" <no*@non.com> wrote in message
news:Of******** ******@TK2MSFTN GP12.phx.gbl... Hi Noozer,
Yes I think you mis something basic, I tried to tell you
I did type it here (Roughly not tested, see it as pseudo, altough I think
it is complete)
2 samples as propertys and as function
I hope this was what you where looking for?
Cor
\\\ Public Class Noozer Private Shared iImages(2) as image 'Holds three images Private Shared pIndex as integer ' holds the index 'Set/Return image for particular state Public shared Read Only Property myImage As image Get Return iImages(pImage) End Get End Property Public shared Property i as integer Get Return pIndex End Get Set (byVal Value as integer) pIndex = Value End Set End Property
'to set and get this this Noozer.index = 1 myImage = Noozer.MyImage
'As a function Public shared function MyImage (byval i as integer) as image return iImages(i) End function
'to get this myImage = Noozer.myimage( 1) ///
Still not what I want though as I need a collection of individual images that could be different sizes.
I know I'm missing something very basic here and I just can't nail it down! Talk about frustrating!
: )
??
How do you set the index? ... Private iImages(2) as image 'Holds three images ...
'Set/Return image for particular state Public Property image(ByVal index As Integer) As image Get Return iImages(index) End Get Set(ByVal index as Integer, ByVal Value As image) '<---Doesn't work.
How Just skip the index parameter above.
Hi Noozer,
Did you try it?
Cor And this will show up as a Collection in the Properties page of my control???
* "Cor" <no*@non.com> scripsit: ?? How do you set the index?
\\\
Private m_Images() As Image ' ...
Public Property Images(ByVal Index As Integer) As Image
Get
Return m_Images(Index)
End Get
Set(ByVal Value As Image)
m_Images(Index) = Value
End Set
End Property
///
Usage
\\\
Dim x As New ...
x.Images(2) = Image.FromFile( ...)
///
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Julian |
last post by:
Hi,
I am using PHP 4 with classes but I have come across a slight problem...
I can't declare an array as a property of a class, ie,
class clTest
{
var $a;
clTest()
|
by: Marc L'Ecuyer |
last post by:
Hi,
I have a collection class derived from CollectionBase. This collection can
add items of my class MyItem. In my class MyItem, I have a Selected
property. When this property is set to true, I have to set this property to
false for all other items in the collection (only 1 item can be selected).
How can I do that?
Thanks
|
by: Faustino Dina |
last post by:
Hi,
The following code is from an article published in Informit.com at
http://www.informit.com/guides/content.asp?g=dotnet&seqNum=142. The problem
is the author says it is not a good idea to return an array as a property
because it will return a copy of the array instead a reference to it. How
can I force the property to return a reference to the array? Is it only a
feature of arrays? I hope normal class objects (including collections)...
|
by: Iain |
last post by:
Hi
I have page (testCal.aspx) that contains a usercontrol (custCalendar.ascx) -
see below signature for code. The UC contains a linkbutton which which when
clicked, posts back and displays a calendar. When a value in the calendar is
selected it posts back and then updates a public property (CurrentDate) on
the UC. Note that 2 postbacks occur.
I have been attempting to access the public property on the UC, from the
page (testCal) shown...
|
by: Gary Kahrau |
last post by:
I hope this is a simple question.
I have a number of usercontrols placed on a form. The usercontrol has
a public property (DispMachine) within it. When looping through the
main form controls, I get an error (not a member of
system.windows.forms.control). However if I put in the explicit name,
VB is happy.
Is it possible to get to this property dynamically?
Or do I have to create a select case (ugly) structure?
| |
by: Ant |
last post by:
Hi,
I'm using the tag property of the Treenode object to store an string array
containing some values. I can assign it to the Tag but when I try to retrieve
values from it I get an error: "Object reference not set to object"
This is what i'm doing below:
// retrieve the array from the treenode tag property
memberInfo = (string)tn.Tag;
|
by: kferron |
last post by:
if i wanted to expose a property on a usercontrol that basically would
work like the way the validators work with the ControlToValidate
property, whats a reliable way of finding the correct control off of a
text property?
I was figuring i could expose a string, allow the consumer to set it,
and then use some technique in the usercontrol to get the reference to
the instance of the control, but i'm not having much luck with actually...
|
by: 12jumper |
last post by:
Hi All :)
I've created an UserControl, which has a couple of properties that are
collections (generic lists of some objects). It would be nice, if
control refreshed each time I add a new item to the collection (using
StringCollectionEditor). Is there any attribute I can use, or perhaps I
have to create a new class that inherites from List<Tand subscribe on
some event? Any suggestions greatly appreciated.
Greetings
|
by: Johnny Jörgensen |
last post by:
Hi y'all
I've got a custom control that is inherited from a normal TextBox. To that,
I've added a new property that I call "Units", Which is a collection class
containing members of a "Unit" class.
When I put my Textbox on the form, I can access the "Units" property from
the IDE's property grid, use the collection designer and add new "Unit"
members to the class.
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |