Saravanan.Chinnusamy

Hi,

I am using DataGridview in my application. In that i am able to display images. when i click the any cell of the datagrid i wanted to open a new Frameless window(which contains some checkboxes and lables) on top of that cell. but i am not able to display that form on top of that cell. i am using the code like this

Point aPoint = dataGridview1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Location;
aForm = new Form();
// aForm.Location = new Point(600,200);
aForm.StartPosition = FormStartPosition.CenterParent;
aForm.Location = new Point(dataGridview1.Location.X + aPoint.X , aPoint.Y);
aForm.Size = new Size(115, 54);
aForm.ControlBox = false;
aForm.FormBorderStyle = FormBorderStyle.None;
aForm.BackColor = Color.Blue;
aForm.TopMost = true;
aForm.Deactivate += new EventHandler(aForm_Deactivate);
aForm.AutoSizeMode = AutoSizeMode.GrowAndShrink;

Can u please tell me how to display that frameless dialog on top of that cell, i am not able to display the form on top.. it is displaying some where..

Thanks in advance



Re: Windows Forms Data Controls and Databinding Help need with DataGridView

Zhi-Xin Ye - MSFT

Hi,Saravanan

Set form's location after showing it, because the Show() method will change the location. Moreover, the GetCellDisplayRectangle method returns location relative to the DataGridView, not a screen point,you need more calculation. To achieve what you want by following this way:

Point aPoint = this.dataGridView2.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex,false).Location;

aPoint.X += this.dataGridView2.Location.X;

aPoint.Y += this.dataGridView2.Location.Y;

aPoint = this.PointToScreen(aPoint);

Form aForm = new Form();

aForm.Size = new Size(115, 54);

aForm.ControlBox = false;

aForm.FormBorderStyle = FormBorderStyle.None;

aForm.BackColor = Color.LemonChiffon;

aForm.TopMost = true;

//aForm.Deactivate += new EventHandler(aForm_Deactivate);

aForm.AutoSizeMode = AutoSizeMode.GrowAndShrink;

aForm.Show();

aForm.Location = aPoint;

Hope it helps.
Best Regards.
Ye