CellClick event and SelectionChanged event in DataGridView?

The best reference for this sort of question is the MSDN DataGridView documentation.

The best reference for this sort of question is the MSDN DataGridView documentation. For the CellClick event they say: This event occurs when any part of a cell is clicked, including borders and padding. It also occurs when the user presses and releases the SPACE key while a button cell or check box cell has focus, and will occur twice for these cell types if the cell is clicked while pressing the SPACE key.

For the SelectionChanged event: This event occurs whenever cells are selected or the selection is canceled, whether programmatically or by user action. For example, this event is useful when you want display the sum of the currently selected cells. The obvious difference is that the CellClick can fire even when the DataGridView selection does not change, for example with a right click or when clicking on the currently selected cell.

Also the selection can change without a cell being clicked, for example when you change the selection programatically. As for when exactly the selection changed event is run in relation to the form load event, when attached in the form constructor it is before (and several times at that! ).

I just proved that to myself with the following code: public Form1() { InitializeComponent(); MyBindingList backing_objects = new MyBindingList(); backing_objects. Add(new BackingObject{ PrimaryKey = 1, Name = "Fred", dataGridView1. DataSource = backing_objects; this.

Load += new EventHandler(Form1_Load); dataGridView1. SelectionChanged += new EventHandler(dataGridView1_SelectionChanged); } void Form1_Load(object sender, EventArgs e) { Console. WriteLine("Load"); } void dataGridView1_SelectionChanged(object sender, EventArgs e) { Console.

WriteLine("Selection Changed"); } The output window reads: Selection Changed Selection Changed Selection Changed Load Note that you can make the selection changed fire after the load event by attaching it during the DataBindingComplete event handler. DataGridView1. DataBindingComplete += new DataGridViewBindingCompleteEventHandler(dataGridView1_DataBindingComplete); void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { dataGridView1.

SelectionChanged += new EventHandler(dataGridView1_SelectionChanged); } Now in the output window you only see: Load And there is no selection changed output until the grid selection is changed (by for example a cell click).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions