Click here to Skip to main content
15,886,919 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: datagridview button column - text not displaying Pin
Simon_Whale31-Mar-10 1:09
Simon_Whale31-Mar-10 1:09 
GeneralRe: datagridview button column - text not displaying Pin
Eddy Vluggen31-Mar-10 1:29
professionalEddy Vluggen31-Mar-10 1:29 
AnswerWhat was the solution ? [Got it] Pin
David Mujica13-Jul-10 3:57
David Mujica13-Jul-10 3:57 
GeneralRe: What was the solution ? Pin
Simon_Whale13-Jul-10 4:04
Simon_Whale13-Jul-10 4:04 
GeneralRe: What was the solution ? Pin
David Mujica13-Jul-10 4:05
David Mujica13-Jul-10 4:05 
GeneralRe: What was the solution ? Pin
HomeSen5-Aug-10 23:17
HomeSen5-Aug-10 23:17 
GeneralRe: What was the solution ? Pin
Bob Stanneveld30-Sep-11 9:20
Bob Stanneveld30-Sep-11 9:20 
AnswerRe: datagridview button column - text not displaying [Solved] Pin
Ajit Yagnesh23-Feb-11 1:38
Ajit Yagnesh23-Feb-11 1:38 
The code is working. just make sure that you apply this after assigning the datasource to your grid control.

Step 1. After assign datasource to grid.
// Add a button column.
DataGridViewButtonColumn buttonColumn =
new DataGridViewButtonColumn();
buttonColumn.HeaderText = "";
buttonColumn.Name = "Status Request";
buttonColumn.Text = "Request Status";
buttonColumn.UseColumnTextForButtonValue = true;

dataGridView1.Columns.Add(buttonColumn);


step2.

just after adding the columns register your click event like below.

// Add a CellClick handler to handle clicks in the button column.
dataGridView1.CellClick +=
new DataGridViewCellEventHandler(dataGridView1_CellClick);


step 3.

now on below event,
void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)

make sure which button is clicked when multiple are there.



if (e.RowIndex < 0 || e.ColumnIndex !=
dataGridView1.Columns["Status Request"].Index) return;

// Retrieve the task ID.
Int32 taskID = (Int32)dataGridView1[0, e.RowIndex].Value;

// Retrieve the Employee object from the "Assigned To" cell.
Employee assignedTo = dataGridView1.Rows[e.RowIndex]
.Cells["Assigned To"].Value as Employee;



========================


Ref: http://msdn.microsoft.com/en-us/library/ms171619.aspx[^]
hello give me code

GeneralRe: datagridview button column - text not displaying [Solved] Pin
Simon_Whale23-Feb-11 1:40
Simon_Whale23-Feb-11 1:40 
QuestionOffice interop printing problem Pin
mSh198530-Mar-10 22:06
mSh198530-Mar-10 22:06 
Questionhelp with displaying hierarchical data in treeview in Visual Basic 2005 Pin
kim67830-Mar-10 21:10
kim67830-Mar-10 21:10 
QuestionNewbie to VB Pin
willwilco30-Mar-10 15:10
willwilco30-Mar-10 15:10 
AnswerRe: Newbie to VB Pin
_Damian S_30-Mar-10 16:05
professional_Damian S_30-Mar-10 16:05 
AnswerRe: Newbie to VB Pin
Wayne Gaylard30-Mar-10 20:38
professionalWayne Gaylard30-Mar-10 20:38 
GeneralRe: Newbie to VB Pin
willwilco31-Mar-10 13:41
willwilco31-Mar-10 13:41 
AnswerRe: Newbie to VB Pin
The Man from U.N.C.L.E.31-Mar-10 7:07
The Man from U.N.C.L.E.31-Mar-10 7:07 
GeneralRe: Newbie to VB Pin
willwilco31-Mar-10 13:42
willwilco31-Mar-10 13:42 
QuestionTwo RadioButtonList.SelectedIndex Values Changed Simultaneously - What am I Doing Wrong? Pin
johnaparker30-Mar-10 11:11
johnaparker30-Mar-10 11:11 
AnswerRe: Two RadioButtonList.SelectedIndex Values Changed Simultaneously - What am I Doing Wrong? Pin
pdnet1-Apr-10 21:46
pdnet1-Apr-10 21:46 
GeneralRe: Two RadioButtonList.SelectedIndex Values Changed Simultaneously - What am I Doing Wrong? Pin
johnaparker3-Apr-10 4:28
johnaparker3-Apr-10 4:28 
Questionhow can i catch form event keydown if my form has datagridview control ? Pin
xingselex30-Mar-10 6:36
xingselex30-Mar-10 6:36 
AnswerRe: how can i catch form event keydown if my form has datagridview control ? Pin
Abhinav S30-Mar-10 6:48
Abhinav S30-Mar-10 6:48 
AnswerRe: how can i catch form event keydown if my form has datagridview control ? Pin
dan!sh 30-Mar-10 6:49
professional dan!sh 30-Mar-10 6:49 
QuestionVB 2008 DataGridView Pin
Filippo197430-Mar-10 5:46
Filippo197430-Mar-10 5:46 
AnswerRe: VB 2008 DataGridView Pin
dan!sh 30-Mar-10 6:12
professional dan!sh 30-Mar-10 6:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.