wesley 3 Posted April 17, 2016 Report Share Posted April 17, 2016 Hey,I'm working with C # and with an if / else statement. But this does not work.With the count you count function the amount of rows in the listbox.The idea is if there are five or fewer rows that one oval (graphic) will be placed and if six or more rows than will show up a different graphic.This does not work because the oval there always will be placed and the other graphic is never executed.My question is: how can I get if / else working?thank you in advance. my code is: private void pnlStatus_Paint(object sender, PaintEventArgs e) { int aantal = haven.Schepen.Count; int number = 5; if (aantal <= number) { Graphics g = e.Graphics; int breedte = 50; int hoogte = 50; g.FillEllipse(Brushes.Green, 10, 10, breedte, hoogte); } else { Graphics gr = e.Graphics; using (Pen p = new Pen(Color.Red, 5)) { gr.DrawLine(p, 0, 0, 50, 50); gr.DrawLine(p, 0, 50, 50, 0); } } } //In the class haven is this the list public List<Schip> Schepen { get { return schepen; } } 1 Quote Link to post Share on other sites
justsomeguy 1,135 Posted April 18, 2016 Report Share Posted April 18, 2016 It sounds like aantal is always less than or equal to number. It would be easy enough to print the values to verify that. Maybe there's something wrong with the value you're getting for aantal. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.