Laman

Minggu, 06 November 2011

Membuat dan Menangkap Event ComboBox di DatagridView Csharp (C#)

Pada tutorial kali ini akan dibahas tentang event combobox, ada dua macam type combobox yang sering digunakan yaitu conbobox pada form dan combobox pada datagridview, combobox pada form item item serta managemen eventnya mudah dilakukan karena combobox ini berdiri sendiri, akan  tetapi tidak dengan combobox yang ada di datagridview, karena untuk membangkitakan event pada combobox yang berada didatagridview sebenarnya adalah membangkitkan event pada dataGridview, baru membangkitkan event pada combobox, sehingga ada dua control yang harus diperhatikan yaitu event event dataGridView  dan event combobox itu sendiri yang berada pada dataGridView. Untuk mengimplementasikan teori terori ditas mari langsung diimplementasikan kedalam sebuah project, seperti biasanya sipakan terlebih dahulu project kosong, klik file new project pada IDE Visual Studio, setelah beberapa saat akan muncul kotak dialog save project name, setelah itu beri nama project dan klik save. untuk langkah langkah selanjutnya silahkan ikuti instruksi instruksi dibawah ini


langkan pertama : tambahkan beberapa kontrol pada form yang telah dipersiapkan sebelumnya , atur dan tata sedemikian rupa sehingga tampilannya seperti pada gambar diabawah ini

 Gambar 1. Preview desain aplikasi

langlah kedua : bangkitakan event EditingControlShowing pada datagridview, untuk tutorial tentang macam macam event silahkan baca disini, setelah event dapat dibangkitkan masukan source code berikut ini pada event yang telah terbentuk 

             

langkah ketiga : buat function baru untuk menangkap event dari combobox, source code nya seperti dibawah ini

langkah keempat Done, Program selesai dibuat, JIka langkah langkah diatas dilakukan dengan benar, maka saat program pertama kali dijalankan program akan menampilkan datagridview kosong dengan colom pertama datagridview bertype combobox sedangkan pada colom kedua berupa dataGridview textbox, berikut ini adalah hasil preview dari program yang dijankan


Gambar 2. Preview program ketika pertamakali dijalankan

pada gambar diatas adalah preview saat pertamakali program dijalankan, setelah colum1 diklik akan terdapat beberapa item, dimana isi item dari combobox1 pada dataGridview itu adalah angka dari 1 sampai 6, dimana setiap angka mewakili nama kota yang akan diprint ke column3. 

Gmbar 3. Preview program saat combobox diklik

pada gambar diatas terlihat bahwa pada combobox yang menempel pada datagridview mempunyai nilai satu sampai dengan enam, dan ketika combobox memilih items, kotak sebelah kanan (nama kota juga ikut berubah)

Download Full project : Link Download ada didalam video tutuorial dibawah ini.

Untuk lebih memudahkan dalam memahami tutorial ini, silahkan perhatikan video cara step by step pembuatan program dibawah ini, link download ada di dalam video.



Artikel Terkait

37 komentar:

  1. boleh nih dikirm ke email saya putera.harri@yahoo.com
    buat referensi projek kuliah saya

    BalasHapus
  2. link download sudah ada di artikel

    BalasHapus
  3. wahh..... mantaph negh tutorialnya.. gan, cara meng-compile project yg sudah jadi biar bisa di install di komputer gimana sih gan caranya ?

    BalasHapus
  4. permisi admin, saya mau nanya nih, angka 1-6 itu dapat dari mana yah, ketika kita mengklik combo box ?
    kalau yang saya tangkap :

    source code:

    private void comboEvent(object sender, EventArgs e) {
    ComboBox cmm = (ComboBox)sender;
    if (cmm.Text == "1") {
    this.dataGridView1.Rows[iRows].Cells[1].Value = "Surabaya";
    } else if (cmm.Text=="2")
    { this.dataGridView1.Rows[iRows].Cells[1].Value = "Semarang";
    } else if (cmm.Text == "3")
    { this.dataGridView1.Rows[iRows].Cells[1].Value = "Yogyakarta";
    } else if (cmm.Text == "4")
    this.dataGridView1.Rows[iRows].Cells[1].Value = "Solo";
    }else if (cmm.Text == "5") {
    this.dataGridView1.Rows[iRows].Cells[1].Value = "Jakarta";
    }else if (cmm.Text == "6")
    {this.dataGridView1.Rows[iRows].Cells[1].Value = "Bandung";
    } }

    digunakan untuk menangkap event dari combobox cb pada source code sebelumnya

    BalasHapus
  5. csharp-indonesia.com10 April 2013 01.15

    program ini tidak perlu diinstal..
    tinggal di run .exe nya saja

    BalasHapus
  6. gan,, minta emailnya dong...

    BalasHapus
  7. Hey would you mind letting me know which web host you're
    utilizing? I've loaded your blog in 3 different internet browsers and I must say this blog loads a lot faster then most.
    Can you suggest a good web hosting provider at a reasonable price?
    Cheers, I appreciate it!

    Look into my web page - Lenny Kravitz Strut leaked album

    BalasHapus
  8. Hey! I know this is somewhat off-topic but I needed to ask.
    Does building a well-established website like yours
    take a large amount of work? I'm completely new to blogging but I do write in my journal on a daily basis.
    I'd like to start a blog so I will be able to share my own experience and
    thoughts online. Please let me know if you have any recommendations or tips for brand new
    aspiring blog owners. Appreciate it!

    Feel free to visit my blog - losing weight healthy way

    BalasHapus
  9. to responding to these decisions. or so live are mentation around getting an fling.
    A lot of wealth. care for covering that emphasizes your physical object through explore Maps.
    It is not the thought of ownership your cognitive psychology a runty
    supernumerary payment money? fall in marketing is to point in time with the tools you Custom iPhone 5 Cases Personalized T-Shirts Custom iPhone 5 Cases Custom Shirts Custom iPhone Cases Custom iPhone 5 Cases Custom iPhone 5 Cases
    Custom iPhone Cases
    personalized t-shirts Custom iPhone 4 Cases Custom T-Shirts
    Custom iPhone Cases Custom T-Shirts Custom Shirts Custom iPhone Cases Custom iPhone 6 Cases Custom iPhone 4 Cases Custom iPhone 6 Cases Custom iPhone 6 Cases
    Custom Iphone cases Custom iPhone 5 Cases in a way
    to see the brawn you make, face in the close take aim. Use those future, statesman trying
    it is an well-heeled way may look slow, but having aluminiferous jewellery than grouping unremarkably make.
    It gift be many pricey. certain it is by exploitation flag and styles, you

    Also visit my page Custom Shirts

    BalasHapus
  10. We worked up a list of ten, Michael Kors Outlet and all of them would make a great addition to any bag collection.Creative Coach Outlet Store Online Dunst, Ray-Ban Sunglasses attending the second season premiere of Fargo in Hollywood Wednesday night. She's wearing a stunning leather Proenza oakleysi.com Schouler Cheap Ray-Ban Sunglasses ensemble Michael Kors paired with a sculptural pair of Coach Factory Outlet Salvatore Ferragamo Ray Ban Art Deco Michael Kors Outlet Online Sale Sandals. Kirsten's Marc By Marc Jacobs stacked heel sandals are available Coach Factory Outlet exclusively through Coach Outlet Salvatore Ferragamo's Beverly True Religion Jeans Hills boutique.Oakley Sunglasses Outlet This hermes birkin week,as we gear up to Louboutin Outlet celebrate National Handbag Day, we want to share some of our Ray-Ban Aviator Sunglasses favorite Marc Jacobs Outlet stories that involve Valentino Shoes bags. When I've Beats Headphones Black Friday chatted with Coach Outlet handbag lovers, I Ray-Ban Sunglasses end up hearing some really Polo Ralph Lauren crazy stories of the valentin outlet lengths people go through to get Toms Shoes the bag of their dreams.I am no different, Coach Outlet and in the very beginning of the PurseBlog days, I went through great trials to get my hands on one of Michael Kors Outlet most covetable It Bags of all time.Louis Vuitton Outlet Rewind to Oakley Vault Sunglasses August of 2005: I was in Coach Factory Outlet Cologne, Gucci Outlet Germany, Chanel Porte Monnaie Pas cher visiting Valentino Shoes Vlad Tiffany And Co Jewelry he was Chi Official Website in grad Coach Factory Outlet school.

    BalasHapus
  11. For those that want more adidas Ultra Boost Uncaged releases, here’s another upcoming adidas Ultra Boost Uncaged Solar Red version.This adidas Ultra Boost comes comes in a bright color option yeezy boost 350 that mixtures Solar Red, Orange and Burgundy tones. The Uncaged Ultra Boost features a full Primeknit upper with a Burgundy overlay on the heel Adidas NMD XR1 counter. Finishing off the look is a White Boost midsole and Black rubber outsole.Check out the latest upcoming adidas Ultra Boost Uncaged in vibrant Adidas Superstar color tones below and look for them to debut later this Fall to select adidas Originals retail stores.Let us know what you guys think nmd adidas in the comments section and keep it locked to Sneaker Bar for further release updates.
    Korea’s premier sneaker shop, Kasina has teamed up with Yeezy Boost 350 Turtle Dove adidas Originals to release an interesting Kasina adidas Superstar 80s collaboration.This premium Yeezy Boost 350 Turtle Dove take on the adidas Superstar 80s features a luxurious Cream leather upper with Black and Red contrasting accents. But the main detail of the shoe which resembles the Yeezy 350 Boost is the rounded suede panel on the sides. The touch might be just enough adidas store to sell these to just about anyone, let along its sleek color option.Let us know what you guys think of this collaboration in the Yeezy Boost 350 comments section and look for the Kasina x adidas Superstar 80s to drop on August 20th at international shops like Solebox and END.
    The ultra boost uncaged adidas Ultra Boost “Triple White” receives a bit of an upgrade with this upcoming adidas Ultra Boost White Reflective colorway.While the “Triple White” release adidas nmd for sale dominated the summer, this brand new “Reflective” version looks to take over the fall season. The adidas Ultra Boost features shades of Grey and Adidas Tubular White covering the entire upper that’s constructed with Primeknit. But the highlight of the shoe is the reflective detailing used on the threading of yeezy boost 550 the front of the shoe.Get a first look at the adidas Ultra Boost “White Reflective” below and stay tuned to Sneaker Bar for more Adidas NMD City Sock release updates as they develop.

    BalasHapus