I am making an app where I have to draw things on a panel. I made a list of "Ellipsis" and draw the Ellipsis to a panel.
Lets say I have 10 Ellipsis drawn on the panel and I want to delete the 5th. How do I do that?
For each ellipse I made a rectangle behind it so that I can click on it.
I know there is a method called: "list1.RemoveAt()". The problem here is that I don't know the index of the list. How do I find the index of an ellipse when clicking on it?
Or shouldn't I use list1.removeAt()?
this is the code:
private void panelUseCase_MouseClick(object sender, MouseEventArgs e)
{
x = e.X;
y = e.Y;
else if (rbUseCases.Checked && radioTest.Checked)
{
foreach (UseCase usecase in usecases)
{
if (x >= usecase.Field.Left && x <= usecase.Field.Right && y >= usecase.Field.Top && y <= usecase.Field.Bottom)
{
int bla = usecases.IndexOf(usecase);
drawuc.RemoveAt(bla);
panelUseCase.Invalidate();
}
}
}
}
The variable usecase
is in this case an ellipse. It's the last if statement from my panelUseCase_MouseClick
method. As you can see, I have drawuc.RemoveAt()
. Yet I have to put an index between (). But I don't know the index and I want to get the index by clicking on a usecase
. Someone got an Idea?