2
My C# Console Application has a list of 7 items in all, and you need to print these items on a label. By default each label fits 5 items. I’m not able to print the items according to the amount of labels.
So what I did (very simply) was:
int nrEtiquetas = Lista.Count / 5
for(int contador = 0; contador <= nrEtiquetas; contador ++)
{
for(int i = 0; i <= 5; i++)
{
MessageBox.Show("Item: " i.ToString())
}
}
EnviaParaImpressora();
Meanwhile the imprint is on loop
and the two remaining items are not displayed.
It seems to me a college job, your problem is not exactly in code but in logic as I understand it... I will not solve the exercise for you but to give you a help, use the following to find the amount of labels:
int nrEtiquetas = (int)Math.Ceiling((double)Lista.Count / 5);
the way it was, it would result in 1.– George Wurthmann
Other than that, take a good look at your loops (for), the logic is wrong :)
– George Wurthmann
Hi George, no... I would really like to be enrolled in a college :( I am just studying by video-classes of udemy. The Math.Ceiling() method always rounds the decimal places to the next value?
– Noob
Yeah, round it up. Start there and try to see where you’re going wrong with the rest, if I just answer here to you I won’t help you with pretty much anything, you won’t learn. Try to structure your problem well you arrive at the expected result :)
– George Wurthmann
Ahh, beauty! thank you very much... this method I did not know in depth. It has given me a light! I will hit more head here kkk :)
– Noob