?
Solved

send updates in Datagridview while datagrid_selectionchanged

Posted on 2011-10-06
2
Medium Priority
?
316 Views
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.
//////////////////////////////////////////////////////////
//////////////////////////DataGrid.cs/////////////////////
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)
        {
            MessageBox.Show("Doubleclick");
        }

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


/////////////////////////////////////////////////////////
/////////////////////Form1.cs///////////////////////////
namespace Circuits
{
    public partial class Form1 : Form
    {
        DataGrid DG1;
        public Form1()
        {
            InitializeComponent();
            DG1 = new DataGrid();
            DG1.DataGridInitialize();
            DG1.eventDataGridView();
            this.Controls.Add(DG1);
            txtCood.Text = DG1.Index_coordinates(0) + "  " + DG1.Index_coordinates(1);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }
    }
}

Open in new window

0
Comment
2 Comments
 
LVL 28

Accepted Solution

by:
strickdd earned 2000 total points
ID: 36933138
Debug the code and make sure that eventDataGridView() is being called (i.e. set a breakpoint there)
0
 

Author Comment

by:Ramanathan Tito Titan Nadar
ID: 36934842
hi, i did manage to solve. thanks for the advice
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

809 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