Hi, I wrote a Forms program which toggles a label each time you click
it:
private void button1_Click(o bject sender, EventArgs e)
{
label1.Text = (label1.Text == "hello") ? "goodbye" :
"hello" ;
}
but in the interest of scaleability, I want this program to store the
label values in a collection, access them via Next() and cycle back to
the beginning when the end of the collection is reached.
Any pointers to something in the .NET library which allows this? 4 1647
metaperl wrote:
Hi, I wrote a Forms program which toggles a label each time you click
it:
private void button1_Click(o bject sender, EventArgs e)
{
label1.Text = (label1.Text == "hello") ? "goodbye" :
"hello" ;
}
but in the interest of scaleability, I want this program to store the
... very enterprisey ;)
label values in a collection, access them via Next() and cycle back to
the beginning when the end of the collection is reached.
Any pointers to something in the .NET library which allows this?
I don't think there is such a collection in the .NET library. You'll
probably have to create your own custom collection.
Besides only adding the label values you could also add delegates to the
collection. This way you could create a method Execute() which executes
the Method associated with the current label.
Max
Well there certainly is a datastructure that can do just this. A queue
Queue<stringfoo = new Queue<string>() ;
foo.Enqueue("He llo");
foo.Enqueue("He llo2");
foo.Enqueue("He llo3");
then whenever you need a string you simply use
string s = foo.Dequeue();
foo.Enqueue(s);
This will provide your wrap around functionality for you.
Cheers,
Greg Young
MVP - C# http://codebetter.com/blogs/gregyoung
"Markus Stoeger" <sp******@gmx.a twrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
metaperl wrote:
>Hi, I wrote a Forms program which toggles a label each time you click it: private void button1_Click(o bject sender, EventArgs e) { label1.Text = (label1.Text == "hello") ? "goodbye" : "hello" ; }
but in the interest of scaleability, I want this program to store the
.. very enterprisey ;)
>label values in a collection, access them via Next() and cycle back to the beginning when the end of the collection is reached.
Any pointers to something in the .NET library which allows this?
I don't think there is such a collection in the .NET library. You'll
probably have to create your own custom collection.
Besides only adding the label values you could also add delegates to the
collection. This way you could create a method Execute() which executes
the Method associated with the current label.
Max
Greg Young wrote:
Well there certainly is a datastructure that can do just this. A queue
Queue<stringfoo = new Queue<string>() ;
foo.Enqueue("He llo");
foo.Enqueue("He llo2");
foo.Enqueue("He llo3");
then whenever you need a string you simply use
string s = foo.Dequeue();
foo.Enqueue(s);
This will provide your wrap around functionality for you.
If we were being polite, we would of course wrap this 'bizarro queue' in
a class called CyclicList<T>, wouldn't we... :)
--
Larry Lard la*******@googl email.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
haha .. yes that we would .. ah the life of a maintenance programmer.
Although I do have a certain fondness for BizarroQueue .. perhaps I would
make it add to the head occasionally too to make it truely bizarre.
"Larry Lard" <la*******@goog lemail.comwrote in message
news:4i******** ****@individual .net...
Greg Young wrote:
>Well there certainly is a datastructure that can do just this. A queue
Queue<stringfo o = new Queue<string>() ; foo.Enqueue("H ello"); foo.Enqueue("H ello2"); foo.Enqueue("H ello3");
then whenever you need a string you simply use
string s = foo.Dequeue(); foo.Enqueue(s) ;
This will provide your wrap around functionality for you.
If we were being polite, we would of course wrap this 'bizarro queue' in a
class called CyclicList<T>, wouldn't we... :)
--
Larry Lard la*******@googl email.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jani Yusef |
last post by:
I have a HW problem stated as shown at the top of the solution. The
thing is is that I am not 100% sure wtf constant memory means. Well, I
think I do but I am confused. Does my solution use contant memory in
terms of the length of the list i? If so why not and how could I
change it to be so? I am sure the solution is O(n) since the list must
only iterated once and the dictionary is O(1), correct?
Thanks for the help!!
#You are given a...
|
by: Joh |
last post by:
hello,
thanks to all who replied to my post (2005-01-21) - (i can not post
inside the original thread as i get "Unable to retrieve message
csr7ep$3db$05$1@news.t-online.com" from googlenews :(
> Do you mean:
> , , , , ,
> (E.g. all elements in the power set except the empty set, the sets with
> one element and the sets with all elements.)
|
by: Michele Simionato |
last post by:
According to the standand library
(http://docs.python.org/lib/typeiter.html)
an *iterable* is something with an __iter__ method. This means that
strings
are *not* iterable. However I can loop over a string without problem
and I would
say that an iterable is anything I can iterate over. Of course I am
*not* proposing
we add __iter__ to strings (it is convenient for me to be able to
distinguish
|
by: Pedro Miguel Carvalho |
last post by:
Greetings.
I'm creating a project that as a intricate relation between object kind of
like a set where each object in the set can be connect to a subset of object
of the set and objects not in the set can connect to objects in the set.
Every object inherits a interface to allow for a mark and sweep garbage
collector (GC) and my implementation works correctly and efficiently but
only in a single thread.
How can I garbage collect in a...
|
by: Richard |
last post by:
Hi,
I'm writing an MS Outlook 2000 Addin in C#. I have
created C# classes that monitor folder events and do other
business logic. Things work fine until I want to exit
Outlook. When I exit Outlook I have to force 2 garbage
collection cycles in order for all of my folder monitor
classes to get cleaned up {else Outlook will not unload
from memory}. In other words my OnDisconnect() method
looks something like this:
| |
by: py |
last post by:
I have function which takes an argument. My code needs that argument
to be an iterable (something i can loop over)...so I dont care if its a
list, tuple, etc. So I need a way to make sure that the argument is an
iterable before using it. I know I could do...
def foo(inputVal):
if isinstance(inputVal, (list, tuple)):
for val in inputVal:
# do stuff
|
by: Benjamin Johnston |
last post by:
Hi,
I've found lots of discussion about the JavaScript garbage collector,
but no clear answer to this question:
Is the garbage collection algorithm used in JavaScript on ASP based on
reference counting or tracing?
Thanks for your help,
|
by: andreas.eisele |
last post by:
I should have been more specific about possible fixes.
In a related thread on http://bugs.python.org/issue2607
Amaury Forgeot d'Arc suggested a setting of the GC
thresholds that actually solves the problem for me:
10 loops, best of 3: 658 msec per loop
|
by: Kurda Yon |
last post by:
Hi,
I found one example which defines the addition of two vectors as a
method of a class. It looks like that:
class Vector:
def __add__(self, other):
data =
for j in range(len(self.data)):
data.append(self.data + other.data)
|
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: 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...
| |
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: 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: 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();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |