send updates in Datagridview while datagrid_selectionchanged

Posted on 2011-10-06
Last Modified: 2012-05-12
Hi, In form1 i have a textbox and what to updates the coordinates when  selectionchanged even triggered.

But i  didn't received updates whenever selection change. Please do assis.
namespace Circuits
    class DataGrid : DataGridView 
        int[] Location_of_gird = new int[2] { 35, 50 };
        int [] Size_of_grid = new int[2]{622,622};
        int Col_row_count = 10;
        int row_height = 62;
        int col_width = 62;
        int [] e_Index =new int[2];

        public void DataGridInitialize()
            this.ColumnCount = Col_row_count;
            this.RowCount = Col_row_count;
            this.AutoSize = false;
            this.DefaultCellStyle.SelectionBackColor = Color.GreenYellow;
            this.GridColor = Color.White;
            this.BorderStyle = BorderStyle.Fixed3D;
            this.CellBorderStyle = DataGridViewCellBorderStyle.None;

            this.Location = new Point(Location_of_gird[0], Location_of_gird[1]);

            this.Size = new Size(Size_of_grid[0], Size_of_grid[1]);

            this.ColumnHeadersVisible = false;
            this.RowHeadersVisible = false;

            foreach (DataGridViewRow row in this.Rows)
                row.Height = row_height;

            foreach (DataGridViewColumn col in this.Columns)
                col.Width = col_width;

        public void eventDataGridView()
            this.DoubleClick += new EventHandler(DataGrid_DoubleClick);
            this.Click += new EventHandler(DataGrid_Click);
            this.SelectionChanged += new EventHandler(DataGrid_SelectionChanged);

        void   DataGrid_SelectionChanged(object sender, EventArgs e)
            e_Index[0] = this.CurrentCell.RowIndex;
            //System.Diagnostics.Debug.Print( "e_index[0] --> " + e_Index[0] + "\n");
            e_Index[1] = this.CurrentCell.ColumnIndex;
            //System.Diagnostics.Debug.Print("e_index[1] --> " + e_Index[1] + "\n");

        void DataGrid_Click(object sender, EventArgs e)
            //throw new NotImplementedException();

        void DataGrid_DoubleClick(object sender, EventArgs e)

        public int Index_coordinates(int i)
            return (e_Index[i]);

namespace Circuits
    public partial class Form1 : Form
        DataGrid DG1;
        public Form1()
            DG1 = new DataGrid();
            txtCood.Text = DG1.Index_coordinates(0) + "  " + DG1.Index_coordinates(1);

        private void Form1_Load(object sender, EventArgs e)

Open in new window

Question by:TITO2009
    LVL 28

    Accepted Solution

    Debug the code and make sure that eventDataGridView() is being called (i.e. set a breakpoint there)

    Author Comment

    hi, i did manage to solve. thanks for the advice

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now