Click here to Skip to main content
15,921,660 members
Home / Discussions / C#
   

C#

 
GeneralRe: Label update Pin
Martin#30-Jan-07 2:55
Martin#30-Jan-07 2:55 
GeneralRe: Label update Pin
imnotso#30-Jan-07 4:00
imnotso#30-Jan-07 4:00 
GeneralRe: Label update Pin
Martin#30-Jan-07 4:05
Martin#30-Jan-07 4:05 
GeneralRe: Label update [modified] Pin
Luc Pattyn30-Jan-07 2:42
sitebuilderLuc Pattyn30-Jan-07 2:42 
AnswerRe: Label update Pin
Jasmine250130-Jan-07 5:53
Jasmine250130-Jan-07 5:53 
GeneralRe: Label update [modified] Pin
imnotso#30-Jan-07 6:13
imnotso#30-Jan-07 6:13 
GeneralRe: Label update Pin
Dan Neely30-Jan-07 6:45
Dan Neely30-Jan-07 6:45 
GeneralRe: Label update Pin
Jasmine250130-Jan-07 18:34
Jasmine250130-Jan-07 18:34 
Is this for a web application or what?

There's a lot of questions here, but the overall application should be extremely simple. No reflection or any of that junk needs to be done here, it's a simple roulette application. Using a bunch of Label controls for the UI isn't the best option, but it's viable.

Anyway, at the beginning of the program, you put all the Labels into one array and you create an array of integers to match. Probably just do this with 37 lines of code, that way, you can rename things later if you want, and you aren't depending on some majick naming scheme to make your app work.

Now, ideally, you are only going to represent one roulette spin each time... so you only have to update one Label and one integer each time... the one you hit. Follow me now? No loops or anything, just a simple event handler that generates your random number and updates a single element of the interface, and a single element of the integer array. C# is strongly typed, so you'll have to convert your int to string...

<br />
int num = (some random number);<br />
spots[num]++;<br />
(labels[num]).Text = spots[num].ToString();<br />


So your initialization is tricky, but then your operational phase is elegant and simple. This is ok as long as it enables a straightforward approach. Think about this in terms of M-V-C...

http://en.wikipedia.org/wiki/Model-view-controller[^]

M = array of integers representing the history of spins (you could also add other simple elements, like maybe a single integer representing the most recent roll)
V = array of Labels (and all the built-in crap that makes them work)
C = Buttons and such on the interface, and your event-handler function


"Quality Software since 1983!"
http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles.

GeneralRe: Label update Pin
Jasmine250130-Jan-07 18:39
Jasmine250130-Jan-07 18:39 
GeneralRe: Label update Pin
imnotso#30-Jan-07 23:17
imnotso#30-Jan-07 23:17 
Questionconvert c# to vb.net Pin
Doritkatz30-Jan-07 1:00
Doritkatz30-Jan-07 1:00 
AnswerRe: convert c# to vb.net Pin
andre_swnpl30-Jan-07 1:19
andre_swnpl30-Jan-07 1:19 
GeneralRe: convert c# to vb.net Pin
Doritkatz30-Jan-07 1:55
Doritkatz30-Jan-07 1:55 
AnswerRe: convert c# to vb.net Pin
Pete O'Hanlon30-Jan-07 1:20
mvePete O'Hanlon30-Jan-07 1:20 
GeneralRe: convert c# to vb.net Pin
Martin#30-Jan-07 1:32
Martin#30-Jan-07 1:32 
AnswerRe: convert c# to vb.net Pin
Dave Doknjas30-Jan-07 13:42
Dave Doknjas30-Jan-07 13:42 
QuestionSending a crypt Email with Attachment Pin
olivier29-Jan-07 23:37
olivier29-Jan-07 23:37 
QuestionGet File Name Pin
ParimalaRadjaram29-Jan-07 23:26
ParimalaRadjaram29-Jan-07 23:26 
AnswerRe: Get File Name Pin
Pete O'Hanlon29-Jan-07 23:33
mvePete O'Hanlon29-Jan-07 23:33 
GeneralRe: Get File Name Pin
ParimalaRadjaram29-Jan-07 23:35
ParimalaRadjaram29-Jan-07 23:35 
GeneralRe: Get File Name Pin
bobsugar22229-Jan-07 23:39
bobsugar22229-Jan-07 23:39 
GeneralRe: Get File Name Pin
ParimalaRadjaram29-Jan-07 23:41
ParimalaRadjaram29-Jan-07 23:41 
GeneralRe: Get File Name Pin
bobsugar22229-Jan-07 23:59
bobsugar22229-Jan-07 23:59 
AnswerRe: Get File Name Pin
engsrini30-Jan-07 0:47
engsrini30-Jan-07 0:47 
GeneralRe: Get File Name Pin
ParimalaRadjaram30-Jan-07 2:51
ParimalaRadjaram30-Jan-07 2:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.