473,324 Members | 2,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

How to add Button in DataGrid

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.
May 29 '06 #1
2 7581
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" <ca********@hotmail.com> wrote in message
news:O3**************@TK2MSFTNGP04.phx.gbl...
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.

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

"Gnic" <ga****@gmail.com> wrote in message
news:OQ**************@TK2MSFTNGP05.phx.gbl...
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" <ca********@hotmail.com> wrote in message
news:O3**************@TK2MSFTNGP04.phx.gbl...
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.


May 29 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
3
by: Zürcher See | last post by:
Someone has implemented a Datagrid Button for the Windows.Form?
3
by: vinayak | last post by:
Hi I am displaying data in Datagrid in ASP.NET with Edit/Update functionality for each row. On the same page I have 2 Button controls which submits the request to server. These button controls...
7
by: A.M | last post by:
Hi, I want to refresh my DataGrid data on every postback. I have following code in Page_Load event, but after first page load, the DataGrid never gets refresh. Here is the code i have in...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
4
by: Baren | last post by:
Hi! All.. I ahve a query related to DataGrid. I used DataReader to populate the DataGrid and it has a Hyperlink Column. On click of the hyperlink i want to pass the complete Row value to another...
0
by: JIM.H. | last post by:
Hello, I have a datagrid object in my web page and when I click a button, datagrid shows the data received from database. Number of columns is defined by the sql string string I gave. Now I...
3
by: Ahsan | last post by:
Hi there I am using datagrid with SQl server I wonder if its possible to create a command button on each row of the grid. Actually I want to open a new form on every button click with...
0
by: arunpandey | last post by:
Friends I am creating columns and edit button in ASP.NET DataGrid at Run Time but when I click on the Edit Button disappears all columns and edit button itself. Only one column remains stay back,...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.