ASp.net

Wednesday, September 9, 2015

How to use Combobox in C#

18 comments:

  1. Method-3:

    private void Getcombodata()

    {
    try
    {
    SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=I:\C3 soft\WindowsFormsApplication2\WindowsFormsApplication2\MTechSqlDatabase.mdf;Integrated Security=True;Connect Timeout=30");
    con.Open();
    string cb = string.Format("Select UnitType From UnitType");
    SqlCommand cmd = new SqlCommand(cb, con);
    SqlDataReader MyReader;
    MyReader = cmd.ExecuteReader();
    while (MyReader.Read())
    {
    string a = MyReader.GetString(0);
    comboBox2.Items.Add(a);
    }
    }
    catch (Exception ex)
    {

    MessageBox.Show(ex.Message );
    }


    }

    ReplyDelete
  2. Method-2:


    private void Getcombodata()

    {
    try
    {
    SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=I:\C3 soft\WindowsFormsApplication2\WindowsFormsApplication2\MTechSqlDatabase.mdf;Integrated Security=True;Connect Timeout=30");
    con.Open();
    string cb = string.Format("Select UnitType From UnitType");
    SqlCommand cmd = new SqlCommand(cb, con);
    SqlDataReader MyReader;
    MyReader = cmd.ExecuteReader();
    while (MyReader.Read())
    {

    comboBox2.Items.Add(MyReader[0]);
    }
    }
    catch (Exception ex)
    {

    MessageBox.Show(ex.Message );
    }
    }

    ReplyDelete
  3. method -1:

    private void Getcombodata()

    {
    SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=I:\C3 soft\WindowsFormsApplication2\WindowsFormsApplication2\MTechSqlDatabase.mdf;Integrated Security=True;Connect Timeout=30");
    SqlCommand cmd = new SqlCommand("Select * From UnitType", con);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataSet dt = new DataSet ();
    da.Fill(dt);

    comboBox2.Items.Clear();

    comboBox2.DataSource = dt.Tables[0];
    comboBox2.DisplayMember = "UnitType";
    }

    ReplyDelete
  4. Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. โป๊กเกอร์ออนไลน์

    ReplyDelete
  5. I’m going to read this. I’ll be sure to come back. thanks for sharing. and also This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article... sabung ayam

    ReplyDelete
  6. This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post! http://www.thejackpotcasino.com/

    ReplyDelete
  7. Great knowledge, do anyone mind merely reference back to it live22

    ReplyDelete
  8. Superior post, keep up with this exceptional work. It's nice to know that this topic is being also covered on this web site so cheers for taking the time to discuss this! Thanks again and again! 안전놀이터

    ReplyDelete
  9. Wow, What an Outstanding post. I found this too much informatics. It is what I was seeking for. I would like to recommend you that please keep sharing such type of info.If possible, Thanks. cmd368

    ReplyDelete
  10. Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. casino bitcoin

    ReplyDelete
  11. Thank you for taking the time to publish this information very useful! allbet

    ReplyDelete
  12. I really impressed after read this because of some quality work and informative thoughts . I just wanna say thanks for the writer and wish you all the best for coming!. BK8 Slot

    ReplyDelete
  13. A very excellent blog post. I am thankful for your blog post. I have found a lot of approaches after visiting your post. Slot Online

    ReplyDelete
  14. You have done a great job on this article. It’s very readable and highly intelligent. You have even managed to make it understandable and easy to read. You have some real writing talent. Thank you. cf68

    ReplyDelete
  15. A very excellent blog post. I am thankful for your blog post. I have found a lot of approaches after visiting your post. dg

    ReplyDelete
  16. Your work is very good and I appreciate you and hopping for some more informative posts. Thank you for sharing great information to us. สล็อตออนไลน์

    ReplyDelete
  17. Thanks for sharing this information. I really like your blog post very much. You have really shared a informative and interesting blog post with people.. 검증사이트

    ReplyDelete
  18. Joker123 slot gaming สล็อตออนไลน์ หากคุณมองหาความสนุกที่มั่นคง เล่นเว็บตรงอันดับหนึ่งเท่านั้น เกมยิงปลา เกมสล็อต บนมือถือ ได้ทุกที่กับ Joker123 ฝากง่ joker 123

    ReplyDelete

MM Online Express | Best product Review and Online Marketing site

MM Online Express | Best product Review and Online Marketing site