How to add Button in DataGrid

G

Gnic

Calros,

Try to add a button control to the DataGridTextBoxColumn.TextBox.Contorls
list

Here is the same code

private DataGridTextBoxColumn _Column;
DataGridTableStyle gridStyle = new DataGridTableStyle();
_Column = (DataGridTextBoxColumn)gridStyle.GridColumnStyles["Column1"];
_Column.TextBox.GotFocus += new EventHandler(Column_GotFocus);

In the Column GetFocus event handler method, add the following lines:

Button columnButton = System.Windows.Forms.Button();
_Column.TextBox.Controls.Add(columnButton);

hope this help.

Gasnic
http://gasnicdev.blogspot.com/
 
C

Calros Lo

Dear All:
I want to add a Button in every head of record in DataGrid , I try to search
about function
in MSDN , but the MS look like not support the function , anybody can tell
me how to or tell me about the information in some website

Thanks.
 
C

Calros Lo

Dear Gnic
Thanks for your reply I'll try it , if I have any question I'll reply you as
soon as possible.

Gnic said:
Calros,

Try to add a button control to the DataGridTextBoxColumn.TextBox.Contorls
list

Here is the same code

private DataGridTextBoxColumn _Column;
DataGridTableStyle gridStyle = new DataGridTableStyle();
_Column = (DataGridTextBoxColumn)gridStyle.GridColumnStyles["Column1"];
_Column.TextBox.GotFocus += new EventHandler(Column_GotFocus);

In the Column GetFocus event handler method, add the following lines:

Button columnButton = System.Windows.Forms.Button();
_Column.TextBox.Controls.Add(columnButton);

hope this help.

Gasnic
http://gasnicdev.blogspot.com/

Calros Lo said:
Dear All:
I want to add a Button in every head of record in DataGrid , I try to
search about function
in MSDN , but the MS look like not support the function , anybody can
tell me how to or tell me about the information in some website

Thanks.
 

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