Jump to content
Son zamanlarda artan kullanıcı hesap hırsızlıkları sebebiyle tüm kullanıcılara şifre sıfırlama maili gönderilmiştir. Lütfen güveli şifreler seçiniz. Mevcut e-mail adresinize erişemiyorsanız, en aşağıdaki destek linkinden bize ulaşınız. ×

Değişken Kullanılarak Form Açma


korasoglu
 Share

Recommended Posts

aşağıdaki örnekte bir form oluşturuyor, bir button oluştuyor, buttonu form'a ekliyor ve formu açıyor:

            Form frm = new Form()
            {
                Size = new Size(300, 200),
                Location = new Point(300, 100)
            };

            Button btn = new Button()
            {
                Text = "düğme"
            };

            frm.Controls.Add(btn);

            frm.Show();

 

  • Like 1
Link to comment
Share on other sites

Bir saat önce, korasoglu yazdı:

Arkadaşlar  değişkene tanımlayarak formları nasıl açtırabilirim.

Form2 d = new Form2();
            d.ShowDialog();

 

bu şekilde değilde değişken özerinden açılmasını istiyorum.

zaten burada değişken kullanmışsınız. Form2 tipinde d değişkeni kullanmışsınız. Ne yapmak istediğinizi tam olarak söylerseniz ona göre bir yol çizelim

Link to comment
Share on other sites

        Form formOlustur(string baslik)
        {
            Form frm = new Form()
            {
                Width = 300,
                Height = 500,
                Text = baslik
            };

            return frm;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form form = formOlustur("Merhaba dünya");
            form.ShowDialog();
        }

 

Link to comment
Share on other sites

  • 2 hafta sonra ...

Hocam ben derdimi anlatma özürlüyüm aynı kodları tekrar etmektense diyelimki 4 tane formum var ben açılacak formun adını göndersem isteğim form açılsa.

Denedim

 

Form2 d = new Form2(); (Form2 yerine değişken yazıyorum kabul etmiyor) mantığına aykırımı ondanmı açmıyor
            d.ShowDialog();

Yani

Form2 d = new Form2(); yerine acilacaksayfam ekl = new acilacaksayfam();diye değişkenle çağırsam olmazmı.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...