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. screen position of control

screen position of control

Scheduled Pinned Locked Moved C#
question
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.
  • E Offline
    E Offline
    Eli Nurman
    wrote on last edited by
    #1

    hi, i am developing a WindowsApplication that when the user clicks on a ListViewItem a Form opens just on the position of the ListViewItem does any one know how is it possible to find out which point on the screen is the control location so i could tell the form where to open? The Control.Position property is not good enough since the control is in a few panels.... The MouseDown event is not good either since this action is accessible thru a context menu strip (which on this case the "MenuItem" may be lower than the ListViewItem)

    S 1 Reply Last reply
    0
    • E Eli Nurman

      hi, i am developing a WindowsApplication that when the user clicks on a ListViewItem a Form opens just on the position of the ListViewItem does any one know how is it possible to find out which point on the screen is the control location so i could tell the form where to open? The Control.Position property is not good enough since the control is in a few panels.... The MouseDown event is not good either since this action is accessible thru a context menu strip (which on this case the "MenuItem" may be lower than the ListViewItem)

      S Offline
      S Offline
      Samer Aburabie
      wrote on last edited by
      #2

      Hi ... I am not sure if I understood you very well ... but what I understood is that you want to show a form where its upper left corner shall be in the upper left corner of a control on the form ... so it comes above it somehow ... anyway ... find the code below and I hope it helps:

      Form2 frm = new Form2();
      frm.StartPosition = FormStartPosition.Manual;
      frm.Location = this.textBox1.PointToScreen(this.textBox1.ClientRectangle.Location);
      frm.Show();

      This will place it exactly at the upper left corner of the control which including the titlebar ... in case you dont want to have the title bar to be it and the client region of the control use this instead:

      Form2 frm = new Form2();
      frm.StartPosition = FormStartPosition.Manual;
      frm.Location = new Point (this.textBox1.X+this.Location.X,this.textBox1.Location.Y+this.Location.Y);
      frm.Show();

      I hope this helps ...

      Sincerely Samer Abu Rabie Note: Please remember to rate this post to help others whom reading it.

      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