How to Insert User Control into DataGrid Cell

T

Tolga

How do insert a user control i have created into a datagrid cell.
Basically i am trying to create a column of my user controls. This is
what i have tried so far.


int i = 0;
while (i < dsSignIn1.Tables["Contacts"].Rows.Count)
{
SignatureControl.SignatureControl sig1 =
new SignatureControl.SignatureControl();
Point p1 = new Point(dgSignIn.GetCellBounds(i,3).X,dgSignIn.GetCellBounds(i,3).Y);//,dgSignIn.GetCellBounds(i,0).Y);
MessageBox.Show(this,p1.ToString());
sig1.Location = p1;
this.Controls.Add(sig1);
i++;
}

I get the cooulmn of the user controls but they show up on the form
behind the datagrid.

How can i get them on the datagrid?
 
T

Telmo Sampaio

I have not done this before, but I remeber seeing that you can add a control
to a Datagrid cell by addin it to the Controls collection of the cell. You
are adding it to the Controls collection of the form now, just positioning
it at the same place as your cell.

Here is a related link used for updating values in a web datagrid:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbcode/h
tml/vbtskcodeupdatingitemsindatagridordatalistwebcontrolvisualbasic.asp

Telmo Sampaio
 
T

Telmo Sampaio

Ignore it. It is only for updating web datagrids...
sorry!
Telmo Sampaio said:
I have not done this before, but I remeber seeing that you can add a control
to a Datagrid cell by addin it to the Controls collection of the cell. You
are adding it to the Controls collection of the form now, just positioning
it at the same place as your cell.

Here is a related link used for updating values in a web datagrid:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbcode/h
tml/vbtskcodeupdatingitemsindatagridordatalistwebcontrolvisualbasic.asp

Telmo Sampaio
Tolga said:
How do insert a user control i have created into a datagrid cell.
Basically i am trying to create a column of my user controls. This is
what i have tried so far.


int i = 0;
while (i < dsSignIn1.Tables["Contacts"].Rows.Count)
{
SignatureControl.SignatureControl sig1 =
new SignatureControl.SignatureControl();
Point p1 = new
Point(dgSignIn.GetCellBounds(i,3).X,dgSignIn.GetCellBounds(i,3).Y);//,dgSign
In.GetCellBounds(i,0).Y);
MessageBox.Show(this,p1.ToString());
sig1.Location = p1;
this.Controls.Add(sig1);
i++;
}

I get the cooulmn of the user controls but they show up on the form
behind the datagrid.

How can i get them on the datagrid?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top