Jump to content

if/else and then graphic


Recommended Posts


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);
            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; } }
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...