C# Tutorial - How to use a Combobox in C#.NET | FoxLearn

Поделиться
HTML-код
  • Опубликовано: 31 май 2024
  • How to use a Combobox in C# Windows Forms. Populating a ComboBox using C#

Комментарии • 20

  • @TheSun_TheMoon_TheStar
    @TheSun_TheMoon_TheStar 4 года назад +2

    Thank you for this, really well made! :)

  • @industrialbro
    @industrialbro Год назад

    Thanks for the tutorial! It was very helpful

  • @Jinx000
    @Jinx000 3 года назад

    say you have a pastebin with names how would u display the pastebin raw stuff in the combo box?

  • @zirconia1205
    @zirconia1205 Год назад

    how to do it if it is in another form? I tried and it works only if the label and combobox is in the same form but doesn't recognize if its on another one

  •  7 месяцев назад

    Thank you hugs form Brazil :)

  • @hoangyennguyenle2603
    @hoangyennguyenle2603 9 месяцев назад

    thanks so much, it's very useful

  • @mansour7
    @mansour7 2 месяца назад +1

    thank you very much 🤍❣️

  • @SuperNatsu25
    @SuperNatsu25 3 года назад

    Thanks

  • @mohameddiallo7202
    @mohameddiallo7202 8 лет назад +2

    please can you do a c# tutorial about how to use a checkbox

    • @foxlearn
      @foxlearn  8 лет назад +2

      +mohamed diallo Thank you for your suggestion. I'll make soon. Thanks ^_^

  • @fantasticevents4679
    @fantasticevents4679 Год назад

    public void PopuniCb()
    {
    SqlCommand komanda = new SqlCommand("Select * From Citalac", konekcija);
    SqlDataAdapter da = new SqlDataAdapter(komanda);
    DataSet ds = new DataSet();
    da.Fill(ds, "Citalac");
    comboBox1.DataSource = ds.Tables["Citalac"];
    comboBox1.DisplayMember = "Ime";
    comboBox1.ValueMember = "CitalacID";
    comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
    }
    private void buttonPrikazi_Click(object sender, EventArgs e)
    {
    try
    {
    SqlCommand komanda = new SqlCommand("Select * From Citalac", konekcija);

    SqlDataAdapter da = new SqlDataAdapter(komanda);
    DataSet ds = new DataSet();
    da.Fill(ds);
    dataGridView1.DataSource = ds.Tables[0];
    }
    catch (Exception)
    {
    MessageBox.Show("Doslo je do greske!");
    }

    }
    }
    }

  • @shovikanand3214
    @shovikanand3214 5 лет назад +1

    nice video.. pls go slow n speak slow n lucid language..

    • @foxlearn
      @foxlearn  5 лет назад +2

      OK. Thank you for your suggestion !

    • @VinyZikss
      @VinyZikss 4 года назад +1

      It's a bot voice...

    • @VTObi4z
      @VTObi4z 3 года назад

      U could watch it in 0.5 or 0.25 speed, subtitles will be slower two.

  • @Raylightsen
    @Raylightsen 7 месяцев назад

    Dude, why the bot voice?... speak with your own.

  • @fantasticevents4679
    @fantasticevents4679 Год назад

    namespace ZadatakA1
    {
    public partial class Form1 : Form
    {
    SqlConnection konekcija = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=;Integrated Security=True;Connect Timeout=30");
    public Form1()
    {
    InitializeComponent();
    }
    private void Form1_Load(object sender, EventArgs e)
    {
    string upiSql = "Select * From Citalac";
    try
    {
    SqlCommand komanda = new SqlCommand(upiSql, konekcija);
    SqlDataAdapter adapter = new SqlDataAdapter(komanda);
    DataSet ds = new DataSet();
    adapter.Fill(ds);
    DataTable dt = ds.Tables[0];
    //adapter.Dispose();
    //komanda.Dispose();
    foreach (DataRow row in dt.Rows)
    {
    ListViewItem listItem = new ListViewItem(row["CitalacID"].ToString());
    listItem.SubItems.Add(row["MaticniBroj"].ToString());
    listItem.SubItems.Add(row["Ime"].ToString());
    listItem.SubItems.Add(row["Prezime"].ToString());
    listItem.SubItems.Add(row["Adresa"].ToString());
    listView1.Items.Add(listItem); // Dodaje red u ListView
    }
    }
    catch (Exception)
    {
    MessageBox.Show("Doslo je do greske!");
    }
    PopuniCb();
    }
    private void buttonUpisi_Click(object sender, EventArgs e)
    {
    if (textBoxBrClanskeKarte.Text != "" && textBoxJmbg.Text != "" && textBoxIme.Text != "" && textBoxPrezime.Text != "" && textBoxAdresa.Text != "")
    {
    try
    {
    SqlCommand command = new SqlCommand("INSERT INTO Citalac(CitalacID, MaticniBroj, Ime, Prezime, Adresa) VALUES(@CitalacID, @Jmbg, @Ime, @Prezime, @Adresa)", konekcija);
    konekcija.Open();
    command.Parameters.AddWithValue("@CitalacID", Convert.ToInt32(textBoxBrClanskeKarte.Text));
    command.Parameters.AddWithValue("@Jmbg", textBoxJmbg.Text);
    command.Parameters.AddWithValue("@Ime", textBoxIme.Text);
    command.Parameters.AddWithValue("@Prezime", textBoxPrezime.Text);
    command.Parameters.AddWithValue("@Adresa", textBoxAdresa.Text);
    command.ExecuteNonQuery();
    konekcija.Close();
    MessageBox.Show("Podaci uspesno upisani");
    PrikaziPodLView();
    ClearData();
    }
    catch (Exception)
    {
    MessageBox.Show("Došlo je do greške");
    }
    }
    else
    {
    MessageBox.Show("Popunite sve podatke!");
    }
    }

  • @fantasticevents4679
    @fantasticevents4679 Год назад

    private void listView1_MouseClick(object sender, MouseEventArgs e)
    {
    textBoxBrClanskeKarte.Text = (listView1.SelectedItems[0].SubItems[0].Text);
    textBoxJmbg.Text = listView1.SelectedItems[0].SubItems[1].Text;
    textBoxIme.Text = listView1.SelectedItems[0].SubItems[2].Text;
    textBoxPrezime.Text = listView1.SelectedItems[0].SubItems[3].Text;
    textBoxAdresa.Text = listView1.SelectedItems[0].SubItems[4].Text;
    }
    private void buttonIzmeni_Click(object sender, EventArgs e)
    {
    if (textBoxBrClanskeKarte.Text != "" && textBoxJmbg.Text != "" && textBoxIme.Text != "" && textBoxPrezime.Text != "" && textBoxAdresa.Text != "")
    {
    try
    {
    SqlCommand command = new SqlCommand("UPDATE Citalac SET CitalacID = @CitalacID, MaticniBroj =@Jmbg, Ime = @Ime, Prezime = @Prezime, Adresa=@Adresa WHERE CitalacID = @CitalacID", konekcija);

    konekcija.Open();
    command.Parameters.AddWithValue("@CitalacID", Convert.ToInt32(textBoxBrClanskeKarte.Text));
    command.Parameters.AddWithValue("@Jmbg", textBoxJmbg.Text);
    command.Parameters.AddWithValue("@Ime", textBoxIme.Text);
    command.Parameters.AddWithValue("@Prezime", textBoxPrezime.Text);
    command.Parameters.AddWithValue("@Adresa", textBoxAdresa.Text);
    command.ExecuteNonQuery();

    konekcija.Close();
    MessageBox.Show("Podaci uspesno izmenjeni");

    PrikaziPodLView();
    ClearData();
    }
    catch (Exception)
    {
    MessageBox.Show("Došlo je do greške");
    }
    }
    else
    {
    MessageBox.Show("Selektujte podatke u GridView-u ili ListView-u koje menjate");
    }
    }

  • @lazarjovanovic7052
    @lazarjovanovic7052 Год назад

    private void buttonDelete_Click(object sender, EventArgs e)
    {
    if (ID != 0)
    {
    try
    {
    SqlCommand command = new SqlCommand("DELETE From Ucenici WHERE UcenikID = @Id", konekcija);
    konekcija.Open();
    command.Parameters.AddWithValue("@Id",ID);
    command.ExecuteNonQuery();
    konekcija.Close();
    MessageBox.Show("Podaci uspesno obrisani");
    PrikaziPodGView();
    PrikaziPodLView();
    ClearData();
    }
    catch (Exception)
    {
    MessageBox.Show("Došlo je do greške");
    }
    }
    else
    {
    MessageBox.Show("Izaberite red koji brišete");
    }
    }