0

When I Click specific cell in DataGridView in my Winform project, let say ColumnIndex 5 , then I want to popup or open a litle form (not MessageBox) in the same position as Clicked Cell. Right now When I click specific cell, then my form opens in center of Screen. But I wont to open iy in the same position or Location of that Clicked Cell. I don't know how, but I think I need to get location or position of Clicked cell and by some how integrate to popup form. This is my code and Test form opens in the middle of screen when I click ColmnIndex 5

private void dgvComputersAdgv_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
     if (e.ColumnIndex == 5)
     { 
        Test ts = new Test(); 
        ts.ShowDialog();
     }
}

Thank you in advance !

Anna
  • 69
  • 1
  • 10

1 Answers1

0

It appears it could be the forms StartPosition property setting. The default choices appear to be Manual, CenterScreen, WindowsDefaultLocation, WindowsDefaultBounds, and CenterParent. Click the in an empty area of the form you want to adjust the StartPosition in Design view. Try out CenterParent or Manual to see if that gets you closer. Otherwise, you will need to update the FormName.Designer.cs - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen to this.Position = System.Windows.Forms.FormStartPosition.custom variable that holds the location........

enter image description here

Nelson
  • 179
  • 4
  • thank you for your response but I want to oppen it as the same position as clicked cell when I click specific cell. I got this link from Jimi who worked fine for me ... this one https://stackoverflow.com/questions/47359798/open-a-form-under-a-datagridview-cell/47361655#47361655 – Anna Mar 08 '21 at 20:51