Click here to Skip to main content
15,896,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to make a event for the button of datagridview.
pls help me on this ..i really need it..

here is my code

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace tushar29
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            initialize_datagridview(5, 5);
        }

        void initialize_datagridview(int rows,
                                      int columns)
        {

            dataGridView1.EditMode = DataGridViewEditMode.EditOnEnter;

            for (int i = 0; (i < columns); i++)
            {
                string i_plus_one = (i + 1).ToString();

                dataGridView1.Columns.Add("Col" + i_plus_one,
                                            "Stage" + i_plus_one);
            }


            dataGridView1.Rows.Add(rows);

///////////////////////////////////////////////////////////////////////////...........button......



            dataGridView1.Rows[0].Cells[0] =
                                        new DataGridViewButtonCell();


            /////////////////////////////////////////////////////////////////////////////////
            dataGridView1.EditingControlShowing +=
                new DataGridViewEditingControlShowingEventHandler(
                    dataGridView1_EditingControlShowing);
        }

        void dataGridView1_EditingControlShowing(
                   object sender,
                   DataGridViewEditingControlShowingEventArgs e)
        { }
    }
}
Posted
Comments
Kenneth Haugland 29-May-14 15:47pm    
WPF or WinForm?
TusharZoo 29-May-14 23:17pm    
for windows form ...
gggustafson 29-May-14 15:51pm    
You are having real problems with the DataGridView control. Go to http://www.4guysfromrolla.com/ and type in DataGridView in the search bar. There is a wealth of really good information there.
TusharZoo 29-May-14 23:17pm    
ok ...thank you for giving me the link ..i am searching but if you have any solution pls give me..

1 solution

Use DataGridView.CellClick to be notified of a mouse click on a cell
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900