Change grid button text at runtime

C

Charlie Dison

Hi there,
How can I change the caption of a button in a grid at runtime? I seem
to be able to change the header text in the column where the button appears
but not the button caption. Thanks in advance.
 
M

[MSFT]

Hi Charlie,

Can you post the HTML code for your DataGrid? With the code, we can get a
idea on how you create the column and header. This can help to determine
how to achieve the issue.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
G

Guest

Hi Luke
I am creating the grid at design time. I simply go into propert
builder, click on columns, and add a button column. The button type is
pushbutton. Is there a way I can set the caption (text) of the push butto
at runtime? Sometimes I want it to say select and other times I want it t
say edit
 
M

[MSFT]

Hi Charlie,

Regarding the issue, you may try following code:

foreach(DataGridItem DemoGridItem in DataGrid1.Items)
{
Button myButton=
(Button)DemoGridItem.Cells[CellIndex].Controls[ControlIndex];
myButton.Text="Select";

}

CellIndex and ControlIndex are zero based integer. You need to change them
to the actural value based on the button's position in the datagrid.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top