Hello,
following decription is very easy.
I have a class UC_Main with constructor where I create EventHandler for SelectionChanged event in MainUCGrid control which is standard DataGridView. MainUCGrid control is part of UC_Main class.
public class UC_Main : UserControl
{
public UC_Main(Evidence.Nodik nod, DataView columns)
{
Initialize();
MainUCGrid.SelectionChanged += new System.EventHandler(MainUCGrid_SelectionChanged);
}
...
...
...
}
Then I have another class called UC_Material.
public partial class UC_Material : UC_Main
...
...
...
I have more classes like UC_Material and I use them to create user controls that are placed in main form. MainUCGrid is initialized in UC_Main so this is the same process for any user control.
When I run code everything is almost fine. I click on any row in MainUCGrid in any user control and SelectionChanged event is fired as I would expect.
Problem is that somewhere during first initialization, I mean when I create instance of any user control, this event is fired 7x and I can not find out why.
How can I find a place in my code that fires this event 7x ?? I thought for example that there is 7 rows in DataGridView or 7 columns but it is not, every user control has different number of rows and columns and event is always fired 7x. Problem is that I can see in debugger that SelectionChanged fires but only thing I know is, that sender is MainUCGrid but I do not know why?? I tried to change SelectionChanged to CellClick and this does not fire 7x.
I do not want to bother with the whole code, at least for now.