Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 14982

C# WinForms position a child dialog with specific coordinates

$
0
0
I can't position a child dialog where I want it. My hardware configuration is a docked laptop with two large monitors, A on the left and B on the right. I don't care where my main application is appearing, but if it's on A then I want my dialog on A also, and same thing if B. I don't want the child dialog centered. There is a grid on the parent form and I want the dialog to initialize underneath the grid, that way the user can see the rows he has selected which are the rows the dialog is operating on.

This child dialog is very annoying becuase if I am running on A it shows up on B. Then if I am running on B it shows up on A. Which is exactly the opposite of what I want!

If I center the child to the parent it's on the correct monitor, but centered it covers up the grid so I want to push it down.

What am I not understanding? Because honestly the logic of this dialog should've been the hard part but that took no time at all compared to how much time this little "icing on the cake" is taking me!!!

Here is the code. Some of it is commented out but you can maybe see what I've tried and hopefully tell me what I am doing wrong currently. Thanks.

Code:

           
using (System_Data_III.frmSystemReleaseQuickSelect frmSystemReleaseQuickSelect = new System_Data_III.frmSystemReleaseQuickSelect(listOfSDC, this.Location.X, this.Location.Y))
{
                frmSystemReleaseQuickSelect.StartPosition = FormStartPosition.Manual;
                frmSystemReleaseQuickSelect.Location = new Point(2543 - this.Location.X, 718 - this.Location.Y);
                frmSystemReleaseQuickSelect.ShowDialog();
}


        List<int> listOfSDC;
        Point newLocation;
        public frmSystemReleaseQuickSelect(List <int> listOfSDC, int parentX, int parentY)
        {
            InitializeComponent();
            this.listOfSDC = listOfSDC;
            // Because I want this form positioned below the list of systems on frmCS so the user can see what he selected and I don't have to repeat it back to him.
            newLocation = new Point(2543 - parentX, 718 - parentY);
        }

        private void frmSystemReleaseQuickSelect_Load(object sender, EventArgs e)
        {
            LoadSystemRelease();

            //StartPosition = FormStartPosition.CenterParent;
            //Location = newLocation;
        }


Viewing all articles
Browse latest Browse all 14982

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>