No overload matches delegate 'System.EventHandler'

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<div style="color:Black;background-color:White; <pre>
Hello experts,
[/code]
i have a inherited winform having 3 tabs , on 2nd tab
<br/>
hello experts,
i have prepayred a basformtab inherited form to use for writing winforms ( as below
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; using System;
<span style="color:Blue; using System.Collections.Generic;
<span style="color:Blue; using System.Data;
<span style="color:Blue; using System.Drawing;
<span style="color:Blue; using System.Data.SqlClient;
<span style="color:Blue; using System.ComponentModel;
<span style="color:Blue; using System.Windows.Forms;
<span style="color:Blue; using CrystalDecisions.Windows.Forms;


<span style="color:Blue; namespace KIToolkit
{
<span style="color:Blue; public <span style="color:Blue; partial <span style="color:Blue; class BaseFormTab : Form
{
<span style="color:Blue; public BaseFormTab()
{
InitializeComponent();
<span style="color:Blue; this.tabPage2.Enter += <span style="color:Blue; new EventHandler(<span style="color:Blue; this.tabPage2_Enter);
}

<span style="color:Blue; string ConnString = <span style="color:Blue; null;
<span style="color:Blue; string _macAdd = <span style="color:Blue; null;
<span style="color:Blue; public System.Collections.ArrayList optor = <span style="color:Blue; new System.Collections.ArrayList();


<span style="color:Blue; public <span style="color:Blue; delegate <span style="color:Blue; void DgvRowHdrDblClickHndlr();
<span style="color:Blue; public <span style="color:Blue; event DgvRowHdrDblClickHndlr BillViewSelect;
<span style="color:Blue; private <span style="color:Blue; void dgv1_RowHeaderMouseDoubleClick(<span style="color:Blue; object sender, DataGridViewCellMouseEventArgs e)
{
<span style="color:Blue; if (e.RowIndex == -1)
<span style="color:Blue; return;
<span style="color:Blue; if (dgv1.Rows[e.RowIndex].Cells[0].Value != <span style="color:Blue; null)
{
<span style="color:Blue; bool yes = <span style="color:Blue; true;
<span style="color:Blue; if (bindNavigator1.Todo.ToString() == <span style="color:#A31515; "Add" || bindNavigator1.Todo.ToString() == <span style="color:#A31515; "Edit")
<span style="color:Blue; if (DialogResult.Yes == MessageBox.Show(<span style="color:#A31515; "Copy to Form", <span style="color:#A31515; "continue With this Record?", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
{
bindNavigator1.btnUndo.PerformClick();
bindNavigator1.btnEdit.PerformClick();
yes = <span style="color:Blue; true;
}
<span style="color:Blue; else
{
yes = <span style="color:Blue; false; <span style="color:Blue; return;
}
<span style="color:Blue; if (yes == <span style="color:Blue; true)
{
KeyValue = dgv1.Rows[e.RowIndex].Cells[Keyfield].Value.ToString();
tabControl1.SelectTab(tabPage1);
}
}
<span style="color:Blue; if (BillViewSelect != <span style="color:Blue; null)
BillViewSelect();

}

<span style="color:Blue; public CrystalReportViewer Crv
{
<span style="color:Blue; get { <span style="color:Blue; return Crv1; }
<span style="color:Blue; set { Crv1 = value; }
}

<span style="color:Blue; protected DataTable DgvSource{<span style="color:Blue; get;<span style="color:Blue; set;}

<span style="color:Blue; protected BindingSource DgvBSSource { <span style="color:Blue; get; <span style="color:Blue; set;}

<span style="color:Blue; public <span style="color:Blue; string KeyValue { <span style="color:Blue; get; <span style="color:Blue; set; }

<span style="color:Blue; public <span style="color:Blue; string Keyfield { <span style="color:Blue; get; <span style="color:Blue; set; }

<span style="color:Blue; public <span style="color:Blue; string[] FieldList{<span style="color:Blue; get;<span style="color:Blue; set;}

<span style="color:Green; //public string getKeyField;

<span style="color:Blue; private <span style="color:Blue; void tabPage2_Enter(<span style="color:Blue; object sender, EventArgs e)
{
<span style="color:Blue; if (DgvSource != <span style="color:Blue; null)
{
<span style="color:Blue; if(dgv1.DataSource==<span style="color:Blue; null)
dgv1.DataSource = DgvSource;
<span style="color:Green; //lblRecordValue.Text = DgvSource.Rows.Count.ToString();
ComboFill();
}
<span style="color:Blue; else <span style="color:Blue; if (DgvBSSource != <span style="color:Blue; null)
{
<span style="color:Blue; if (dgv1.DataSource == <span style="color:Blue; null)
dgv1.DataSource = DgvBSSource;
<span style="color:Green; //lblRecordValue.Text = DgvBSSource.Count.ToString();
ComboFill();
}
<span style="color:Green; //FieldName.DataSource = FieldList;

}

<span style="color:Blue; private <span style="color:Blue; void ComboFill()
{
<span style="color:Blue; foreach (DataGridViewColumn dgvc <span style="color:Blue; in dgv1.Columns)
{
<span style="color:Blue; if (!FieldName.Items.Contains(dgvc.Name))
FieldName.Items.Add(dgvc.Name);
}
}

<span style="color:Blue; #region UnUsed
<span style="color:Blue; public <span style="color:Blue; void ChangeControlStatus(<span style="color:Blue; bool status)
{
<span style="color:Blue; foreach (Control c <span style="color:Blue; in tabControl1.Controls)
<span style="color:Blue; foreach (Control ctrl <span style="color:Blue; in c.Controls)
<span style="color:Blue; if (ctrl <span style="color:Blue; is KIToolkit.EnterKeyTextBox)
{
ctrl.BackColor = Color.White;
((KIToolkit.EnterKeyTextBox)ctrl).Enabled = status;
}
<span style="color:Blue; else <span style="color:Blue; if (ctrl <span style="color:Blue; is KIToolkit.MaskTextBox)
{
ctrl.BackColor = Color.White;
((KIToolkit.MaskTextBox)ctrl).Enabled = status;
}
<span style="color:Blue; else <span style="color:Blue; if (ctrl <span style="color:Blue; is TextBox)
{
ctrl.BackColor = Color.White;
((TextBox)ctrl).Enabled = status;
}
<span style="color:Blue; else <span style="color:Blue; if (ctrl <span style="color:Blue; is DateTimePicker)
((DateTimePicker)ctrl).Enabled = status;
<span style="color:Blue; else <span style="color:Blue; if (ctrl <span style="color:Blue; is Button)
((Button)ctrl).Enabled = status;
<span style="color:Blue; else <span style="color:Blue; if (ctrl <span style="color:Blue; is RadioButton)
((RadioButton)ctrl).Enabled = status;
<span style="color:Blue; else <span style="color:Blue; if (ctrl <span style="color:Blue; is KIToolkit.NvgnBar)
((KIToolkit.NvgnBar)ctrl).Enabled = <span style="color:Blue; true;
<span style="color:Blue; else <span style="color:Blue; if (ctrl <span style="color:Blue; is CheckBox)
((CheckBox)ctrl).Enabled = status;
<span style="color:Blue; else <span style="color:Blue; if (ctrl <span style="color:Blue; is ComboBox)
{
ctrl.BackColor = Color.White;
((ComboBox)ctrl).Enabled = status;
}
<span style="color:Blue; else <span style="color:Blue; if (ctrl <span style="color:Blue; is TabControl)
((TabControl)ctrl).Enabled = <span style="color:Blue; true;

}

<span style="color:Green; //public void GetSetDelToolText(DataTable dtTable)
<span style="color:Green; //{
<span style="color:Green; // List<string> lChilds = KIToolkit.GetParentChild.GetChildTables(dtTable);
<span style="color:Green; // bool bFlag = false;
<span style="color:Green; // string sDeleteToolText = null;
<span style="color:Green; // foreach (string table in lChilds)
<span style="color:Green; // {
<span style="color:Green; // int iCnt = KIToolkit.GetParentChild.DataCount(table);
<span style="color:Green; // if (iCnt > 0)
<span style="color:Green; // {
<span style="color:Green; // bindNavigator1.btnDelete.Enabled = false;
<span style="color:Green; // sDeleteToolText += table + " Contains " + iCnt.ToString() + " Records" + "n";
<span style="color:Green; // bFlag = true;
<span style="color:Green; // }
<span style="color:Green; // }

<span style="color:Green; // if (!String.IsNullOrEmpty(sDeleteToolText) && bFlag == true)
<span style="color:Green; // bindNavigator1.btnDelete.ToolTipText = sDeleteToolText;
<span style="color:Green; // else
<span style="color:Green; // {
<span style="color:Green; // bindNavigator1.btnDelete.ToolTipText = "Delete";
<span style="color:Green; // bindNavigator1.btnDelete.Enabled = true;
<span style="color:Green; // }
<span style="color:Green; //}


<span style="color:Blue; public <span style="color:Blue; void bindingBtnsEnableDisable()
{
<span style="color:Blue; if (bindNavigator1.BindingNavigator1.BindingSource.Count == 0)
{
bindNavigator1.btnMoveLast.Enabled = <span style="color:Blue; false;
bindNavigator1.btnMoveFirst.Enabled = <span style="color:Blue; false;
bindNavigator1.btnMoveNext.Enabled = <span style="color:Blue; false;
bindNavigator1.btnMoveLast.Enabled = <span style="color:Blue; false;
bindNavigator1.btnDelete.Enabled = <span style="color:Blue; false;
bindNavigator1.btnEdit.Enabled = <span style="color:Blue; false;
<span style="color:Blue; return;
}
<span style="color:Blue; else
{
bindNavigator1.btnDelete.Enabled = <span style="color:Blue; true;

bindNavigator1.btnEdit.Enabled = <span style="color:Blue; true;
}
<span style="color:Blue; if (bindNavigator1.BindingNavigator1.BindingSource.Position ==
bindNavigator1.BindingNavigator1.BindingSource.Count - 1)
{
bindNavigator1.btnMoveNext.Enabled = <span style="color:Blue; false;
bindNavigator1.btnMoveLast.Enabled = <span style="color:Blue; false;
bindNavigator1.btnMoveFirst.Enabled = <span style="color:Blue; true;
bindNavigator1.btnMovePrevious.Enabled = <span style="color:Blue; true;
}
<span style="color:Blue; else
{
bindNavigator1.btnMoveNext.Enabled = <span style="color:Blue; true;
bindNavigator1.btnMoveLast.Enabled = <span style="color:Blue; true;
bindNavigator1.btnMoveFirst.Enabled = <span style="color:Blue; true;
bindNavigator1.btnMovePrevious.Enabled = <span style="color:Blue; true;
}
}
<span style="color:Blue; #endregion

<span style="color:Blue; public <span style="color:Blue; void SetTranTypeStatus()
{
<span style="color:Blue; if (!String.IsNullOrEmpty(ConnString))
{
_macAdd = Mac.GetLocalStandaloneMacAdr();
<span style="color:Blue; if (String.IsNullOrEmpty(_macAdd))
_macAdd = Mac.GetLocalProcessorID();
SqlConnection conn = <span style="color:Blue; new SqlConnection(Appvaribales.ConnectionString);
conn.Open();
SqlCommand cmd = <span style="color:Blue; new SqlCommand(<span style="color:#A31515; "SetTranType", conn);
cmd.CommandType = CommandType.StoredProcedure;
<span style="color:Blue; try
{
<span style="color:Blue; if (!String.IsNullOrEmpty(<span style="color:Blue; this.bindNavigator1.Table) &&
!String.IsNullOrEmpty(_macAdd) &&
!String.IsNullOrEmpty(<span style="color:Blue; this.bindNavigator1.SetTranTypeTo.ToString()) &&
!String.IsNullOrEmpty(<span style="color:Blue; this.bindNavigator1.SetTranType.ToString()) &&
<span style="color:Blue; this.bindNavigator1.SetTranTypeTo.ToString().ToUpper() != <span style="color:#A31515; "NONE" &&
<span style="color:Blue; this.bindNavigator1.SetTranType.ToString().ToUpper() != <span style="color:#A31515; "NONE")
{
SqlParameter[] para = <span style="color:Blue; new SqlParameter[6];
para[0] = <span style="color:Blue; new SqlParameter(<span style="color:#A31515; "@tablename", <span style="color:Blue; this.bindNavigator1.Table);
para[1] = <span style="color:Blue; new SqlParameter(<span style="color:#A31515; "@macaddress", _macAdd);
para[2] = <span style="color:Blue; new SqlParameter(<span style="color:#A31515; "@key1", <span style="color:Blue; this.bindNavigator1.Key1);
para[3] = <span style="color:Blue; new SqlParameter(<span style="color:#A31515; "@key2", <span style="color:Blue; this.bindNavigator1.Key2);
para[4] = <span style="color:Blue; new SqlParameter(<span style="color:#A31515; "@trantypeTo", <span style="color:Blue; this.bindNavigator1.SetTranTypeTo.ToString());
para[5] = <span style="color:Blue; new SqlParameter(<span style="color:#A31515; "@trantype", <span style="color:Blue; this.bindNavigator1.SetTranType.ToString());
cmd.Parameters.AddRange(para);
cmd.ExecuteNonQuery();
conn.Close();
}
}
<span style="color:Blue; catch (SqlException)
{
conn.Close();
}
}
}

<span style="color:Blue; private <span style="color:Blue; void BaseFormTab_FormClosed(<span style="color:Blue; object sender, FormClosedEventArgs e)
{
SetTranTypeStatus();
}

<span style="color:Blue; private <span style="color:Blue; void BaseFormTab_Load(<span style="color:Blue; object sender, EventArgs e)
{
pnl3.BringToFront();
pnl3.Visible = <span style="color:Blue; false;
<span style="color:Green; //pnl2.BringToFront();
<span style="color:Green; //pnl2.Visible = false;
<span style="color:Blue; this.rdlPreview1.Visible = <span style="color:Blue; false;
<span style="color:Green; //this.rdlPreview1.refreshReport();
}
<span style="color:Blue; private <span style="color:Blue; void BaseFormTab_KeyDown(<span style="color:Blue; object sender, KeyEventArgs e)
{
<span style="color:Blue; if (e.KeyCode == Keys.Enter)
{
Control cntr = ActiveControl;
<span style="color:Blue; if (cntr <span style="color:Blue; is TextBox)
{
TextBox tt = (TextBox)cntr;
<span style="color:Blue; if (!tt.Multiline)
SendKeys.Send(<span style="color:#A31515; "{TAB}");
}
<span style="color:Blue; else <span style="color:Blue; if (cntr <span style="color:Blue; is RichTextBox)
{
RichTextBox rt = (RichTextBox)cntr;
<span style="color:Blue; if (!rt.Multiline)
SendKeys.Send(<span style="color:#A31515; "{TAB}");
}
<span style="color:Blue; else
SendKeys.Send(<span style="color:#A31515; "{TAB}");
}
<span style="color:Blue; if (e.KeyCode == Keys.Alt && e.KeyCode == Keys.Enter)
{
<span style="color:Blue; this.pnl2.BringToFront();
<span style="color:Blue; this.pnl2.Visible = <span style="color:Blue; false;
}
<span style="color:Blue; if (e.KeyCode == Keys.Escape)
{
<span style="color:Blue; this.pnl2.SendToBack();
<span style="color:Blue; this.pnl2.Visible = <span style="color:Blue; true;
}
}

<span style="color:Blue; private <span style="color:Blue; void bindNavigator1_PrintPreview()
{
<span style="color:Green; //TabPage otp = new TabPage();
<span style="color:Green; //if (!tabControl1.TabPages.ContainsKey("tabPage3"))
<span style="color:Green; //{
<span style="color:Green; //otp.Name = "tabPage3";
<span style="color:Green; //otp.Text = "Print Priview";
<span style="color:Green; //PrintPreviewControl ppc = new PrintPreviewControl();
<span style="color:Green; //tabControl1.TabPages.Add(otp);
<span style="color:Green; //otp.Controls.Add(ppc);
<span style="color:Green; //ppc.Controls.Add(Crv);
<span style="color:Green; //ppc.Dock = DockStyle.Fill;
<span style="color:Green; //Crv.Dock = DockStyle.Fill;
<span style="color:Green; //tabControl1.SelectTab(otp);
<span style="color:Green; //}
<span style="color:Green; //else if (tabControl1.TabPages.ContainsKey("tabPage3"))
tabControl1.SelectTab(<span style="color:#A31515; "tbP3");
}



<span style="color:Blue; private <span style="color:Blue; void bindNavigator1_Search()
{
<span style="color:Blue; if (DgvSource != <span style="color:Blue; null)
dgv1.DataSource = DgvSource;
<span style="color:Blue; else <span style="color:Blue; if (DgvBSSource != <span style="color:Blue; null)
dgv1.DataSource = DgvBSSource;
}

<span style="color:Blue; private <span style="color:Blue; void dgvMultiSearch_CellEnter(<span style="color:Blue; object sender, DataGridViewCellEventArgs e)
{
<span style="color:Blue; if (e.ColumnIndex != 1)
<span style="color:Blue; return;
<span style="color:Blue; if (dgvMultiSearch.Rows[e.RowIndex].Cells[0].Value == <span style="color:Blue; null ||
dgvMultiSearch.Rows[e.RowIndex].Cells[0].Value == DBNull.Value)
<span style="color:Blue; return;

optor.Clear();

<span style="color:Blue; string colname = dgvMultiSearch.Rows[e.RowIndex].Cells[0].Value.ToString();

<span style="color:Green; //if (dgv1.Columns[colname[1]].ValueType == typeof(System.DateTime) ||
<span style="color:Green; // dgv1.Columns[colname[1]].ValueType == typeof(System.Decimal))
<span style="color:Blue; if (dgv1.Columns[colname].ValueType == <span style="color:Blue; typeof(System.DateTime))
{
dgvMultiSearch.Rows[e.RowIndex].Cells[2].ToolTipText = <span style="color:#A31515; "DD.MM.YYYY OR DD/MM/YYYY";
}

<span style="color:Blue; if (dgv1.Columns[colname].ValueType == <span style="color:Blue; typeof(System.String))
{
<span style="color:Green; //if (!optor.Contains("="))
optor.Add(<span style="color:#A31515; "=");
<span style="color:Green; //if (!optor.Contains("!="))
optor.Add(<span style="color:#A31515; "!=");
<span style="color:Green; //if (!optor.Contains("like"))
optor.Add(<span style="color:#A31515; "like");

optor.Add(<span style="color:#A31515; "is null");
}
<span style="color:Blue; else
{
<span style="color:Green; //if(!optor.Contains( "))
optor.Add(<span style="color:#A31515; ");
<span style="color:Green; //if(!optor.Contains("<"))
optor.Add(<span style="color:#A31515; "<");
<span style="color:Green; //if (!optor.Contains("="))
optor.Add(<span style="color:#A31515; "=");
<span style="color:Green; //if (!optor.Contains("!="))
optor.Add(<span style="color:#A31515; "!=");
<span style="color:Green; //if (!optor.Contains("like"))
optor.Add(<span style="color:#A31515; "like");

optor.Add(<span style="color:#A31515; "is null");
}

operatorname.DataSource = optor;
}

<span style="color:Blue; private <span style="color:Blue; void dgv1_CellDoubleClick(<span style="color:Blue; object sender, DataGridViewCellEventArgs e)
{
<span style="color:Blue; this.pnl2.BringToFront();
<span style="color:Blue; this.pnl2.Visible = <span style="color:Blue; false;
}

<span style="color:Blue; private <span style="color:Blue; void bindNavigator1_BeforeAddnew()
{
<span style="color:Blue; if (tabControl1.SelectedTab != tabPage1)
tabControl1.SelectTab(tabPage1);
}

<span style="color:Blue; private <span style="color:Blue; void bindNavigator1_AfterEdit()
{
<span style="color:Blue; if (tabControl1.SelectedTab != tabPage1)
tabControl1.SelectTab(tabPage1);
}

<span style="color:Blue; #region UnUsed
<span style="color:Green; //private void txtSearchValue_TextChanged(object sender, EventArgs e)
<span style="color:Green; //{
<span style="color:Green; // if (!string.IsNullOrEmpty(CmbSearchField.Text) && !string.IsNullOrEmpty(txtSearchValue.Text))
<span style="color:Green; // {
<span style="color:Green; // if (DgvSource != null)
<span style="color:Green; // {
<span style="color:Green; // string s = "Convert(" + CmbSearchField.Text.Trim() + ",System.String) LIKE %" + txtSearchValue.Text + "%";
<span style="color:Green; // DataView dv = new DataView(DgvSource, s, "", DataViewRowState.OriginalRows);
<span style="color:Green; // //DataRow[] dr = DgvSource.Select(""+CmbSearchField.Text + " = " + txtSearchValue.Text+"");
<span style="color:Green; // if (dv.Count != 0)
<span style="color:Green; // {
<span style="color:Green; // dgv1.DataSource = dv;
<span style="color:Green; // label2.Text = dv.Count.ToString();
<span style="color:Green; // }
<span style="color:Green; // }
<span style="color:Green; // else if (DgvBSSource != null)
<span style="color:Green; // {
<span style="color:Green; // DgvBSSource.Filter = "Convert(" + CmbSearchField.Text.Trim() + ",System.String) LIKE %" + txtSearchValue.Text + "%";
<span style="color:Green; // if (DgvBSSource != null)
<span style="color:Green; // {
<span style="color:Green; // dgv1.DataSource = DgvBSSource;
<span style="color:Green; // label2.Text = DgvBSSource.Count.ToString();
<span style="color:Green; // }
<span style="color:Green; // }
<span style="color:Green; // }
<span style="color:Green; //}
<span style="color:Blue; #endregion
}
}

[/code]
<br/>
),
it have a gridview dgv1 on the second tab, i want to overload the <span style="font-family:Consolas; font-size:x-small

<span style="font-family:Consolas; font-size:x-small
dgv1_RowHeaderMouseDoubleClick in the new forms which i create using above baseformtab as under
<span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; font-size:x-small


<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; this.dgv1.RowHeaderMouseDoubleClick += <span style="color:Blue; new EventHandler(<span style="color:Blue; this.BillViewSelect_Click);

<span style="color:Blue; private <span style="color:Blue; void BillViewSelect_Click(<span style="color:Blue; object sender, DataGridViewCellMouseEventArgs e)
{
MessageBox.Show(<span style="color:#A31515; "Hello");
}
[/code]
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
but i am getting error
Error 2 No overload for BillViewSelect_Click matches delegate System.EventHandler D:vs2010Kings ERPFinancialInvoice1.cs 28 52 Kings ERP
can u figure out what wrong i m doing, to avoide above error
thank u for vour valuable time masters

<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small






View the full article
 
Back
Top