🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / C# / .dll de form oluşturmak ve dll içinde dll çağırmak

1-) C# -

.dll de form oluşturmak ve dll içinde dll çağırmak

 

1-) windows form aplication

 

private void button1_Click(object sender, EventArgs e)

        {

            f_dll.Class1 al = new f_dll.Class1();

            al.Goster();

        }

2-)f_dll nin içi //burası dll yani class library

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

 

namespace f_dll

{

    public class Class1

    {

        TextBox t, t1;

 

        public void Goster()

 

        {

 

            Form form = new Form();

            form.Text = "ramazan haber";

            Button b1 = new Button();

            t = new TextBox();

            t1 = new TextBox();

            t.SetBounds(5, 5, 100, 100);

            t1.SetBounds(5, 50, 100, 100);

            b1.SetBounds(5, 150, 50, 50);

            b1.Text = "dll aç";

            b1.Click += new EventHandler(button_Click);

 

            form.Controls.Add(t);

            form.Controls.Add(t1);

            form.Controls.Add(b1);

            form.Show();

 

        }

        protected void button_Click(object sender, EventArgs e)

        {

            Form form = new Form();

            form.Text = "haber";

            f_dll1.Class2 dll2 = new f_dll1.Class2();

            dll2.topla(Convert.ToInt32(t.Text), Convert.ToInt32(t1.Text));

            Label sonuc = new Label();

            sonuc.Text = dll2.topla(Convert.ToInt32(t.Text), Convert.ToInt32(t1.Text)).ToString();

            form.Controls.Add(sonuc);

            form.Show();

        }

    }

}

 

3-)f_dll1 in içi  //burası dll yani class library

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace f_dll1

{

    public class Class2

    {

       public int topla(int a,int b)

        {

            return a + b;

        }

    }

}

 2021 Ocak 18 Pazartesi
 501