Coordinates - Control Relative To The FORM - "Control.Location DUH!!"

Nov 13, 2008

I have a control on a form - I need to know the coordinates of that control relative to the FORM.

Now before I get six replies saying, "Control.Location DUH!!" that only works when the control's parent IS the form. What if the control is nested inside one or more container controls?

Could I write a routine that crawls up all parent containers until I reach the form calculating each offset as I go? Sure! But this extremely crude operation seems clunky to me - What I'm looking for is something a little cleaner.

So far the closest I've been able to come is this:
Dim ClientPoint As Point = Ctrl.PointToScreen(Ctrl.Location)
Dim LocationLeft As Integer = (ClientPoint.X - Ctrl.ParentForm.Left) - Ctrl.Left
Dim LocationTop As Integer = (ClientPoint.Y - Ctrl.ParentForm.Top) - Ctrl.Top

The problem with the above code is: It does NOT take the Form's border or Titlebar into consideration... so this calculated location would be off slightly depending on what kind of border the form has.

View 3 Replies


ADVERTISEMENT

Get X And Y Coordinates Of A Control's Location On Form Relative To Screens Top Left Corner?

May 23, 2009

How can I get x and y coordinates of a control's location on a form relative to the Screens Top Left corner?

For example, if I have 3 labels on a form and I want label2 and label3 to display the x and y of label1 relative to the screens top and left corner.

When running the app, as the form's possition is changed label 2 and 3 update the coordinate of Label1's possition relative to the top left of the screen.

View 6 Replies

Set Control (windows Control) Position To Some Other Control Relative Postion?

Mar 25, 2011

I want to set control position relative to other control so when i make one control hide then other control move up like this.

View 1 Replies

Translate MouseEventArg.Location X,y Pixel Coordinates To Custom Grid Coordinates?

Nov 29, 2010

I want to translate MouseArgEvent.Location (x,y) coordinates into my custom graph coordinates. Mouse Y coordinates increase from top to bottom while my grid's y value increase from bottom to top. Given my following code, I would need to create 21,500 separate conditional expression for 100(y) x 215(x) possible coordinate locations for my grid.

Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
If e.X > 48 AndAlso e.X < 50 AndAlso e.Y > 397 AndAlso e.Y < 399 Then
MessageBox.Show("about 0,0")

[code]....

View 5 Replies

Persist Control Location On A Form?

Jun 16, 2010

I need to save the controls location and size on the parent form to file. My aim is to be able to simply copy that file to the path where an instance of my program is running and then it automatically applies the previously saved layout of controls. How can I use My.Settings to do that or is there another better option?

View 12 Replies

VS 2010 Changing Control Parent Property Changes Control Location Position?

Feb 16, 2011

I'm trying to make a program with transparent labels over pictureboxes and when I set the label Parent to the PictureBox the position of the label changes.

View 2 Replies

String Popup Location Of A Form Control?

Feb 22, 2012

After a little research, I managed to get a working Help button added to my form. I did this by setting the MinimizeBox and MaximizeBox properties of the form to false, set the ShowHelp property of the form to true and added a HelpProvider component. I then added a string to each control's HelpString property that I want to display help on.

Everything works with one minor exception. When I clcik the help button in the form and then select a control, the HelpString (tooltip) is displayed in the far lower left corner of the screen. I assumed I would see this pop up at the cursor rather than where it is. I cannot seem to find a property to control the position of the HelpString popup.

View 3 Replies

Get Another Application Relative Coordinates?

Jun 17, 2009

I'm writting a small program to send data to another application.Have not probs with that, my only problem now is to get the coordinates relative to the screen of that application so I don't need to move it, when I start the application, or to avoid probs if the customer moves that application on the screen.Currently this is my code to find if the other application is running or not, and if running then move it to the left upper corner of the screen.

Dim nWnd As IntPtr
Dim ceroIntPtr As New IntPtr(0)
Dim Wnd_name As String
Wnd_name = "thisname"

[code]....

View 2 Replies

Location - Get The Nearest Control To A Control Of Choice?

May 14, 2010

Is there an easy way to get the nearest control to a control of choice? I have a picture box and some other moving controls. I want to delete the nearest control to my picture box. So I have to get the position of all controls and delete that with the Location nearest to the Location of my picture box. I'm not sure about how to do that the best way.

View 2 Replies

Keeping Control Locations Relative On Maximize?

May 22, 2011

I'm trying to figure out how to keep control locations relative on maximize. For example, if i have a button on the very right hand of my window, when i maximize it, i want the button to remain on the very right hand. Or when i grow my window, i want my controls to change location so its always relative to the size of the window. how can i achieve this?

EDIT: To provide a better example, if i have a window with a button in the center, when i maximize that window the button should remain in the center rather than in the same location as before and therefore being out of place.

View 5 Replies

Cursor - Get The Position Of The Mouse Relative To The Browser Control

May 13, 2010

I have a hobby of making webbrowsers. I'm writing a new one, but it has an old webbrowser control in it (CEXWB). This means that I am using IHTMLDocument(s) rather than normal HTMLDocuments. I'm in the process of implementing a ContextMenu, but I need to get the position of the mouse relative to the browser control, so using something like Cursor.Position won't work. The Webbrowser_MouseMove event also won't work. I'm not sure why. I also can't use WithEvents with a HtmlDocument (like in my webbrowser ContextMenu tutorial) as I cannot Convert A System.Windows.Forms.HtmlElement into an mshtml.IHTMLDocument2.

So far, I have this code:

'The event which fires when the ContextMenu for the browser Opens
Private Sub cmenuWB_PopupOpen(ByVal sender As Object, ByVal e As DevComponents.DotNetBar.PopupOpenEventArgs) Handles cmenuWB.PopupOpen

[CODE]...

How I could implement this?

View 3 Replies

Get Mouse Coordinates On A Control Behind An Another?

Dec 23, 2011

Is there any way to get the mouse coordinates on a control behind an another control.

The exact scenario is, I have a picture box of size 1024*1024 and and an another picture box of size 256*256 over the bigger picture box (of size 1024*1024). Now, when I move my mouse over smaller picture box, I want the mouse coordinates with respect to the bigger picture box behind the smaller picture box on which the mouse is moved.

View 1 Replies

Add Crosshairs Or Popup Of X,y Coordinates On Mouse Hover For This Graph Control?

Nov 21, 2010

This control takes in an array and plots a bar chart type 'count' along the Y axis for a corresponding X location. A user has requested to be able to mouse hover over any location on the graph and have it display the X and Y coordinates.

Option Strict On
Option Explicit On
Imports System.Windows.Forms

[Code]....

View 6 Replies

Simulate Mouse Click On Webbrowser Control Based On Coordinates?

Mar 6, 2011

How do I simulate mouse click on webbrowser control based on coordinates (x, y).Coordinates of the webbrowser control. I wanna click a specific location on the webbrowser.

View 5 Replies

Location Of DOS Window Relative To Form1?

Mar 31, 2010

I am calling a program that runs in DOS screen.Is it possible to position this screen to always open exactly same cordinates relative to my FORM1 screen?Or is it possible to run the FORM1 to start at same screen cordinates all the time?

The Code:

Sub Install1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Install1.Click
instance = Process.Start(Application.StartupPath & "Driver.exe")
instance.WaitForExit()
End Sub

View 7 Replies

VS 2008 - Draggable Control And AutoScroll - Allow Moving A Control On A Form At Run-time

Dec 26, 2009

The following code works perfectly to allow moving a control on a form at run-time. However, when AutoScroll is set to True on Form1, and you drag Button1 past the right and/or bottom bounds of the form, it goes haywire. I really need someway to smoothing control the autoscroll so that as you scroll the control off the form, the scrollbars smoothly appear.

[Code]...

View 1 Replies

Copy To The Clipboard Using CNTRL/C On A Menustrip - Copying Text From One Control To Another Control On A MDI Child Form?

Aug 19, 2009

I am still messing around with Cntrl/Copy and Paste from a menustrip. Paste is working fine. The copy is working to a certain extent. It will copy the complete text field from one control to another. how do I determine what is the selected text only. My code below:

Private Sub CopyToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CopyToolStripMenuItem.Click
Dim activeChild As Form = Me.ActiveMdiChild ' Determine the active child form.
Dim activeControl As Control = activeChild.ActiveControl

[code]....

View 4 Replies

One Trigger A Click Event In A UserControl From The Main Form's Tab Index Control That Contains An Instance Of The User Control?

Jan 5, 2011

The code is listed below which hopefully illustrates what I'm trying to do:[code]....

View 12 Replies

Panel On A Main Form Containing A PictureBox Control On Top Of A TableLayout Control

Mar 15, 2010

I've got a Panel on a main Form containing a PictureBox control on Top of a TableLayout control. Both the child controls have their docking properties set to Top. The Picture control has sizemode set to Zoom.

What I'm finding is that the picture doesn't size properly when I start the app. There is a border at the top and bottom in the PictureBox control. It's only when I resize the overall form that it's correct.

So at the moment I've got this ugly bit of startup code, just to fix the problem Me.WindowState = FormWindowState.Normal Me.WindowState = FormWindowState.Maximized

What am I missing?

View 2 Replies

Set CommandTarget Of WPF Control As Textbox Which Is Written In Win Form User Control?

Feb 10, 2010

i want to set the CommandTarget property of menu item to the TextControl which is written in win form or just tell me any way which can execute the command lets say cut copy paste on the control which is written in win form user control and added to xaml through WindowsFormsHost

View 1 Replies

Form Control - Using Listbox Or Drag And Drop Control?

Jul 6, 2011

I have a form set up with a few text boxes for first name last name and job title and i got the class for EditDialog. vb. The question is I have to drop some controls onto the form to make a generic add and edit employee dialog. Now would I use the listbox or drag and drop control?

View 2 Replies

Get Selected Textbox Location Coordinates?

Aug 8, 2011

I have a form called main with 10 number of text boxes.my second small form called popup & I want to appear right corner of selected text box. Ex - when I click 1st text box, I want to appear the popup next to the firs text box, then I click 2nd text box I want to move popup to 2nd text box.

so I used

New Point(10 + Me.Location.X + SerchTextBox.Width + SerchTextBox.Location.X, 20 + Me.Location.Y + SerchTextBox.Height + SerchTextBox.Location.Y)

the problem is I have large no of textboxes & difficult to changed each textbox name each place.

If I can get selected textbox coordinates X & Y its easy & compact. How can I find selected text box location.

View 2 Replies

Control Resize With Form User Control?

Oct 8, 2011

I have a user control which contains some textboxes,buttons ,labels and comboboxes . I used that control in a form and inside a split contaier.Splitter can be moved by the user. User control is docked as fill.

Now when user move the splitter the user control size is changes as it is dock fill but the inner controls used in that user control looks like fixed in a single place .It are not moving nor resizing .How to do this .Is there any property to perform thisI already know about anchor property but sometimes it causes overlapping of controls so I can not use it.

View 11 Replies

Forms :: Control The Load Location Of An App?

Mar 19, 2009

I am developing a windows app in VS2008 to be used along side ESRI�s ArcMap. Most ArcMap users will have dual monitors and I would like the user to be able to choose which monitor my app is loaded on to.

When I deploy the app using the standard install package, the app will load onto which ever monitor the user places the desktop shortcut. However, when using the ClickOnce method of deployment, the placement of the shortcut does not matter and the app always loads on the primary display monitor.

Is there a way to control where an app is loaded by code or any other method?

View 1 Replies

How To Give Location To Control T Runtime

Mar 27, 2010

I am trying to add textbox at runtime. but my problem is textbox is

added on same location but i want to add textbox at different location.

Code that i am using is :[code...]

View 2 Replies

Image Location In The Splitter Control?

Aug 13, 2011

I am working on splitter control in winform, I want to insert the image in the splitter and make the image location to stay at the same place in the splitter when I am moving them.

When i am moving the splitter, the image will move around in winform which it is a messy.

Code:
Public Class Form1
Private Sub Splitter1_SplitterMoved(ByVal sender As System.Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles Splitter1.SplitterMoved

[Code]....

View 1 Replies

Picturebox Control Location On Screen?

Dec 17, 2009

I have a picturebox (pbRows) that I want to always be aligned with the right side of the screen. The form may be wider than this (I have a horizontal scrollbar), but the picturebox always needs to be along the right edge of the screen. Currently I have this code snippet in the form_load subroutine:

Dim rowsX As New Integer rowsX = Screen.PrimaryScreen.Bounds.Width - pbRows.Width pbRows.Location = New Point(rowsX, 25) However, the picturebox is aligned with the right edge of the form (initially hidden off the screen). Am I missing something obvious?

View 13 Replies

Button Control Move From Its Original Location

Nov 1, 2010

i made a little from control which hold 3 button controls lined, in the designer they're all lined up perfectly but when i built and ran the application the middle button shift a bit to the left and overlap the left control, someone has any idea why its happen ?

View 1 Replies

Control Installation Location Of Click Once Folders?

Sep 8, 2009

Is there any way to change the installion of a click once app to the program files location so that it will be availabe to all users? Right now it is burying the location of the files within the user folder.

View 2 Replies

Forms :: Copy A Control And Place It In Another Location?

Sep 10, 2011

Does anyone know how to copy a control (button, panel etc...) and place the control with the same click event on another part of a form while keeping the original in the same location? I have a custom user control that I created that has special features on click. If I have the control on the left side and want to drag it over to the right side I want the control duplicated, as this control can be duplicated unlimited times, and still have the same click event.

[Code]...

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved