Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Hi , I help needed in events and graphics

Hi , I help needed in events and graphics

Scheduled Pinned Locked Moved C#
graphicshelpquestioncsharpwinforms
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 3950922
    wrote on last edited by
    #1

    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 ?

    L 1 Reply Last reply
    0
    • U User 3950922

      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 ?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You can store all your bars as an array of Rectangles 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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups