How to embed DataGridView in dll

I want to create a dll with following function, but when i compile i face error,

Error 1 The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference ) D:\ClassLibrary1\Class1.cs 9 48 ClassLibrary1

How to solve this problem, is there any alternative method solve this problem.

public void fillDataGrid(System.Windows.Forms.DataGridView DataGridName, string DataMemeberName, string Query, System.Data.SqlClient.SqlConnection ConnectionToDatabase, System.Windows.Forms.Form frm)

{

if (ConnectionToDatabase != null)

{

System.Data.DataSet ds = new System.Data.DataSet();

System.Data.SqlClient.SqlDataAdapter ad = new System.Data.SqlClient.SqlDataAdapter(Query, ConnectionToDatabase);

ad.Fill(ds, DataMemeberName);

DataGridName.DataSource = ds;

DataGridName.DataMember = DataMemeberName;

ad = null;

ds = null;

}

}




Answer this question

How to embed DataGridView in dll

  • Matti-Koopa

    Yes, Done

    Thank You Once Again



  • Dietz

    add the System.Windows.Forms assembly in your project as well as importing the namespace however I wouldnt suggest placing some UI Component in a dll. UI components should be done at the GUI level of the application

  • How to embed DataGridView in dll