Menampilkan Data Dari form1 ke Form duan pada C#


Menampilka Data Diri dan Gambar pada Form2 dengan Inputan dan Kontrol Pada Form1

langkah pertama Buka Visual Studio dan Masuk ke WindowsFromApplication,.
Lalu akan Muncul Form kosong,. dan isikan ToolBox Di bawah ini,..

ToolBox

Tool Box pada Form1 ToolBox Pada Form2
Button1TabPage

Tab1

TextBox1

TextBox2

ComboBox1

RadioButton1

RadioButton2

ChekBox1

ChekBox2

ChekBox3

ChekBox4

Tab2

Button2

PictureBox1

RichBox1PictureBox1

Aturlah Posisi Dari masing masing toolbox seperti pada gambar di bawah,.

Biarkan Propertisnya Deafult

Biarkan Propertisnya Deafult

Lalu ketikan Listing Program Berikut Pada Form1.cs,.

List koding Form1

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace latihanShowDataDiri

{

publicpartialclassForm1 : Form

{

public Form1()

{

InitializeComponent();

}

privatevoid button1_Click(object sender, EventArgs e)

{

DialogResult dr = openFileDialog1.ShowDialog();

if (dr == DialogResult.OK)

{

pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);

Form2 d = newForm2();

d.pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);

}

else

{

pictureBox1.Image = Image.FromFile(null);

}

}

privatevoid Form1_Load(object sender, EventArgs e)

{

comboBox1.Items.Add(“Islam”);

comboBox1.Items.Add(“Kristen”);

comboBox1.Items.Add(“Katolik”);

comboBox1.Items.Add(“Hindu”);

comboBox1.Items.Add(“Budha”);

}

privatevoid button2_Click(object sender, EventArgs e)

{

string a, b, c, d, f;

if (radioButton1.Checked == true)

{

a = “Laki-laki”;

}

else

{

a = “Perempuan”;

}

if (checkBox1.Checked == true)

{

b = “Catur”;

}

else

{

b = “”;

}

if (checkBox2.Checked == true)

{

c = “Tenis”;

}

else

{

c = “”;

}

if (checkBox3.Checked == true)

{

d = “Renang”;

}

else

{

d = “”;

}

if (checkBox4.Checked == true)

{

f = “Shopping”;

}

else

{

f = “”;

}

Form2 baru = newForm2();

baru.pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);

baru.richTextBox1.Text = “Nama\t\t:” + textBox1.Text + “\nAlamat\t\t: ” + textBox2.Text

+ “\nAgama\t\t: ” + comboBox1.SelectedItem + “\nJenis Kelamin\t: ” + a +

“\nHobi\t\t: ” + b + c + d +f;

baru.Show();

}

}

}

Disain Form2

Kemudian Aturlah Toolbox utuk form2 yang ada di tabel atas sesuai Pada gambar di Bawah,.

Biarkan Propertisnya Deafult

Biarkan Propertisnya Deafult

Masukan Kode Program di bawah ke dalam form2.cs,.

List Koding Form2

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace latihanShowDataDiri

{

publicpartialclassForm2 : Form

{

public Form2()

{

InitializeComponent();

}

privatevoid pictureBox1_Click(object sender, EventArgs e)

{

}

}

}

Cara Menambah Tab baru

  1. KlikkananPada Tab
  2. Pilih Add Tab

Jika sudah Periksa Kembali Pada Form2.disainer jadikan RichBox dan Picturebox Menjadi Public,. Jika di biarkan Privat Maka Form2 tidak bisa di control dari form satu, karena class method nnya masih privat dam itu berarti tidak bisa di panggil, karena khusus untuk form2,.

Jika Persiapan Dan Pengeditan Semua Benar Maka Tampilan pertama Saat di Run

  • Tampilan Tab1
Tampilan Tab1

Tampilan Tab1

  • Tampilan Tab2
Tampilan Tab2

Tampilan Tab2

Tampilan Tab2 Masih kosong maka, klik pilih Gambar(Button1) untuk memilih file gambar yang anda inginkan,.

Saya Memilih File Gambar Cewe

Saya Memilih File Gambar Cewe

seperti di atas saya memilih foto cewe cantik nan manis,. hihihi🙂

Disini Ada Program khusus,. kenapa bisa muncul di fomr1 ini kuncinya

DialogResult dr = openFileDialog1.ShowDialog();

if (dr == DialogResult.OK)

            {

                pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);

}

Tampilan Saat Tombol Tampilkan(Button2) Di klik

Tampilan Akhir

Tampilan Akhir

Semoga Membantu,..🙂

25 thoughts on “Menampilkan Data Dari form1 ke Form duan pada C#

  1. Ping-balik: Penjelasan Privat, Protected dan Publice Pada C# | New Choice

  2. Hi I am so glad I found your website, I really found you by accident, while
    I was researching on Yahoo for something else, Regardless I
    am here now and would just like to say kudos for a remarkable post and a all round enjoyable blog (I also love the theme/design),
    I don’t have time to read it all at the minute but I have bookmarked it and also added your RSS feeds, so when I have time I will be back to read much more, Please do keep up the great work.

  3. Ping-balik: Cara mengambil seluruh data pada ListBox,, how to retrieve all the data in the listbox,, (C#) | New Choice

  4. Pretty nice post. I just stumbled upon your blog and wanted to say that I’ve really enjoyed browsing your blog posts. In any case I will be subscribing to your rss feed and I hope you write again soon!

  5. Today, while I was at work, my sister stole my apple ipad and tested to see if
    it can survive a forty foot drop, just so she can be a youtube sensation.
    My iPad is now broken and she has 83 views. I know this is entirely off topic but I had
    to share it with someone!

  6. hello there and thank you for your info – I’ve definitely picked up something new from right here. I did however expertise some technical issues using this site, since I experienced to reload the site lots of times previous to I could get it to load correctly. I had been wondering if your web host is OK? Not that I am complaining, but sluggish loading instances times will very frequently affect your placement in google and could damage your quality score if ads and marketing with Adwords. Well I am adding this RSS to my email and could look out for much more of your respective interesting content. Ensure that you update this again very soon.

  7. Hmm it seems like your site ate my first comment (it was super long) so I guess I’ll just sum it up what I wrote and say, I’m thoroughly enjoying your blog. I too am an aspiring blog blogger but I’m still new to the whole thing. Do you have any tips for newbie blog writers? I’d definitely appreciate it.

  8. I know this if off topic but I’m looking into starting my own blog and was wondering what all is needed to get setup? I’m assuming having a blog like
    yours would cost a pretty penny? I’m not very web smart so I’m not 100% positive. Any recommendations or advice would be greatly appreciated. Many thanks

  9. Thanks for expressing your ideas. One thing is that scholars have an option between federal government student loan as well as a private education loan where it can be easier to choose student loan debt consolidation loan than with the federal student loan.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s