By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,543 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,543 IT Pros & Developers. It's quick & easy.

Extended Datagrid link even errors

P: 5
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.Form1.cs_LinkClicked does not match delegate"
can anyone please help?
Thanks for all the help.

here is my code:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
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.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
BindControls();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
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 InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.d ataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
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.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(544, 414);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.d ataGrid1)).EndInit();
this.ResumeLayout(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("AuthorName", 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.com";

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

dmTable.Rows.Add(row2);

DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = "Test";
ColumnStyles.ColumnStyles.DataGridLinkLabelColumn cs = new ColumnStyles.ColumnStyles.DataGridLinkLabelColumn( );
cs.LinkClicked += new System.EventHandler(this.cs_LinkClicked);

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

ts.GridColumnStyles.Add(cs);


dataGrid1.TableStyles.Add(ts);
dataGrid1.DataSource = dmTable;
}

private void cs_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
MessageBox.Show("You have clicked a link");
}
}
}
Dec 19 '06 #1
Share this Question
Share on Google+
1 Reply


P: 5
I have found the anwer to this. All I had to do is add this instead.

cs.LinkClicked+=new ColumnStyles.ColumnStyles.DataGridLinkLabelColumn. LinkLabelLinkClickedEventHandler(cs_LinkClicked);
Dec 19 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.