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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...