Hi , I help needed in events and graphics
-
I am using csharp to create a user control for creating bar graphs, The user control will use rectangles as bars, (drawn using gdi+). I am adding this user control to a form, Now when i focus each bar in the user control instance on the form , it should raise a mouse hover event. I am unable to identify when the mouse is over the rectangle. I do not want to calculate the position of mouse and then check what is drawn at what pixel and then raise the event. I want some ideas on how to identify each bar or rectangle individually from the main form. Is it possible or I am just imagining ? Hope you guys understand my problem ?
-
I am using csharp to create a user control for creating bar graphs, The user control will use rectangles as bars, (drawn using gdi+). I am adding this user control to a form, Now when i focus each bar in the user control instance on the form , it should raise a mouse hover event. I am unable to identify when the mouse is over the rectangle. I do not want to calculate the position of mouse and then check what is drawn at what pixel and then raise the event. I want some ideas on how to identify each bar or rectangle individually from the main form. Is it possible or I am just imagining ? Hope you guys understand my problem ?
You can store all your bars as an array of
Rectangle
s or encapsulate them inside a bar class, like that:class Bar
{
public Color Color;
public Rectangle Extends
public string Name;
}You can then loop around all bars and check whether
Rectangle.Contains(cursorPoint)
. regards