Extended Datagrid link even errors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • VanZandt
    New Member
    • Oct 2006
    • 5

    Extended Datagrid link even errors

    I have a class(dll) that extends winform datagrid to provide link column in vb.net. I have managed to create a datagrid in c# winforms that shows link in one of the column but when I try to create a EventHandler I get a compilation error:
    "Method 'DataGridLink.F orm1.cs_LinkCli cked does not match delegate"
    can anyone please help?
    Thanks for all the help.

    here is my code:

    using System;
    using System.Drawing;
    using System.Collecti ons;
    using System.Componen tModel;
    using System.Windows. Forms;
    using System.Data;

    namespace DataGridLink
    {
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows. Forms.Form
    {
    private System.Windows. Forms.DataGrid dataGrid1;

    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.Componen tModel.Containe r components = null;
    public Form1()
    {
    //
    // Required for Windows Form Designer support
    //
    InitializeCompo nent();
    BindControls();
    //
    // TODO: Add any constructor code after InitializeCompo nent call
    //
    }
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null)
    {
    components.Disp ose();
    }
    }
    base.Dispose( disposing );
    }

    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeCompo nent()
    {
    this.dataGrid1 = new System.Windows. Forms.DataGrid( );
    ((System.Compon entModel.ISuppo rtInitialize)(t his.dataGrid1)) .BeginInit();
    this.SuspendLay out();
    //
    // dataGrid1
    //
    this.dataGrid1. DataMember = "";
    this.dataGrid1. HeaderForeColor = System.Drawing. SystemColors.Co ntrolText;
    this.dataGrid1. Location = new System.Drawing. Point(0, 0);
    this.dataGrid1. Name = "dataGrid1" ;
    this.dataGrid1. Size = new System.Drawing. Size(544, 408);
    this.dataGrid1. TabIndex = 0;
    //
    // Form1
    //
    this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
    this.ClientSize = new System.Drawing. Size(544, 414);
    this.Controls.A dd(this.dataGri d1);
    this.Name = "Form1";
    this.Text = "Form1";
    ((System.Compon entModel.ISuppo rtInitialize)(t his.dataGrid1)) .EndInit();
    this.ResumeLayo ut(false);
    }
    #endregion

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
    Application.Run (new Form1());
    }

    private void BindControls()
    {
    DataTable dmTable = new DataTable("Test ");
    dmTable.Columns .Add(new DataColumn("SNo ", typeof(int)));
    dmTable.Columns .Add(new DataColumn("Aut horName", typeof(string)) );
    dmTable.Columns .Add(new DataColumn("Web Address", typeof(string)) );

    DataRow row = dmTable.NewRow( );
    row["SNo"] = 1;
    row["AuthorName "] = "A";
    row["Web Address"] = "http://www.downloads.c om";

    dmTable.Rows.Ad d(row);
    DataRow row2 = dmTable.NewRow( );
    row2["SNo"] = 2;
    row2["AuthorName "] = "B";
    row2["Web Address"] = "http://www.hotmail.com ";

    dmTable.Rows.Ad d(row2);

    DataGridTableSt yle ts = new DataGridTableSt yle();
    ts.MappingName = "Test";
    ColumnStyles.Co lumnStyles.Data GridLinkLabelCo lumn cs = new ColumnStyles.Co lumnStyles.Data GridLinkLabelCo lumn();
    cs.LinkClicked += new System.EventHan dler(this.cs_Li nkClicked);

    cs.MappingName = "Web Address";
    cs.HeaderText = "Web Address";

    ts.GridColumnSt yles.Add(cs);


    dataGrid1.Table Styles.Add(ts);
    dataGrid1.DataS ource = dmTable;
    }

    private void cs_LinkClicked( object sender, LinkLabelLinkCl ickedEventArgs e)
    {
    MessageBox.Show ("You have clicked a link");
    }
    }
    }
  • VanZandt
    New Member
    • Oct 2006
    • 5

    #2
    I have found the anwer to this. All I had to do is add this instead.

    cs.LinkClicked+ =new ColumnStyles.Co lumnStyles.Data GridLinkLabelCo lumn.LinkLabelL inkClickedEvent Handler(cs_Link Clicked);

    Comment

    Working...