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
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!"); }
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"); } }
Thank you for this, really well made! :)
Thanks for the tutorial! It was very helpful
say you have a pastebin with names how would u display the pastebin raw stuff in the combo box?
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
Thank you hugs form Brazil :)
thanks so much, it's very useful
thank you very much 🤍❣️
Thanks
please can you do a c# tutorial about how to use a checkbox
+mohamed diallo Thank you for your suggestion. I'll make soon. Thanks ^_^
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!");
}
}
}
}
nice video.. pls go slow n speak slow n lucid language..
OK. Thank you for your suggestion !
It's a bot voice...
U could watch it in 0.5 or 0.25 speed, subtitles will be slower two.
Dude, why the bot voice?... speak with your own.
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!");
}
}
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");
}
}
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");
}
}