public DataGridViewC()
{
this.GridColor = Color.Green;
this.BackgroundColor = Color.Linen; this.VirtualMode = true;
this.AllowUserToAddRows = false;
this.AllowUserToDeleteRows = false;
this.AllowUserToOrderColumns = true;
this.ReadOnly = true;
this.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
this.AllowUserToResizeColumns = true;
this.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
this.DataSource = null;
this.DataSourceChanged += new EventHandler(GridViewDataSourceChanged);
AddContextMenu();
GC.Collect();
}问题:其中 this.DataSourceChanged += new EventHandler(GridViewDataSourceChanged); 这句话的意思是不是:DataSourceChanged激法是,就执行 GridViewDataSourceChanged方法?
{
this.GridColor = Color.Green;
this.BackgroundColor = Color.Linen; this.VirtualMode = true;
this.AllowUserToAddRows = false;
this.AllowUserToDeleteRows = false;
this.AllowUserToOrderColumns = true;
this.ReadOnly = true;
this.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
this.AllowUserToResizeColumns = true;
this.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
this.DataSource = null;
this.DataSourceChanged += new EventHandler(GridViewDataSourceChanged);
AddContextMenu();
GC.Collect();
}问题:其中 this.DataSourceChanged += new EventHandler(GridViewDataSourceChanged); 这句话的意思是不是:DataSourceChanged激法是,就执行 GridViewDataSourceChanged方法?
this.DataSourceChanged += new EventHandler(GridViewDataSourceChanged);
如果同样的代码重复写两行,那在事件触发时,方法GridViewDataSourceChanged可能会执行两次。