I am fairly new to C# so forgive me if this is a simple question but I cannot seem to find anything on this subject (I am proabably not searching for the correct thing)
How would you go about setting form control properties such as a succession of many label's text properties dynamically after an event trigger such as a button click?
For an example of a snippit of code I am toying with...
I don't think that is an issue. It works when I use the first code. Also when I output the first set of numbers (let's say 5 numbers) then change it so that it outputs 7 numbers it will not change the original 5 but show the other 2 numbers.
It is almost like the original numbers that are generated are on top of the subsequent numbers thus not showing them.
So I guess what I need is a way to redraw the form on button click event.
Are you clearing the array before you generate the new numbers?
Yeah, I was. I wasn't at first but that was one of my steps and I caught it then (so it's kinda good that this happened lol)
Anyway, I figured out what to do!!! WOOT!
It was obvious too :eek:
I was forgetting about the BringToFront() Label method.
What was happening is that it would generate the number and display it. But it would do so underneath the existing displayed number, effectivly stacking them one on top of the other.
You add this property to your generated labels then it puts the new one on top, thus displaying it:mrgreen:
Are you placing the labels adjacent to one another then? Sorrie I don't have my c# compiler at the mo.
Yes, but not directly adjacent to one another.
I thought it was solved (and it sorta was). I now have it so that the text generated is on top of the previously generated text.
However, on a subsequent click, if you have requested an output that is less than the previous time (i.e. it produced and output 5 numbers then you choose 3) the former numbers (the original 2 numbers in the previous example) remain. Sidenote: I am learning C#/VS 2005. My girlfriend comes up with little ideas and I am making them so that I can have experience. So this is not a critical thing per say.
Here are some screenshots to help visualize what is going on...
AH HAH! As you can see, 3 of the original numbers (in blue) remain! That is no good
The label and text generation that was required on the click event was successful. It created 3 label controls and assigned text to them.
Last edited by DDoSAttack; Mar 24th, 2007 at 6:34 pm.
Ok so I came up with a workaround. I don't like it much. It heavily relies upon setting a fixed amount of "blank" labels to cover up the previously generated labels.
Basically, I created a refresh method that is called for each generate button click. Here's the code...
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.