RowFocusChanged Event in datagrid?

I couldn’t find this event in dataGridview control, it seems in world they have a selectedIndexChanged event but winForm doesn’t. The closest one might be CurrentCellChanged, my translate code is:

        private int _currentRowIndex = -1;

        private void dataGridView1_CurrentCellChanged(object sender, EventArgs e)
            if (dataGridView1.CurrentRow == null) return;

            if (_currentRowIndex == dataGridView1.CurrentRow.Index) return;

            // I put my processing code in this method.
            dataGridRowChanged(sender, e);

            _currentRowIndex = dataGridView1.CurrentRow.Index;

Which looks very stupid. To make it a little bit nicer, I can use Concurrency Manager instead.

 set {
                this.dataGridView1.DataSource = value;

                dataGridCurrentRowChanged(null, null);

                // Setup Concurrency Manager.
                    .CurrentChanged += new EventHandler(dataGridCurrentRowChanged);


Phew! UI coding is hard.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s