Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (appleduardo):

how to compare numbers with listbox?

OpenStudy (appleduardo):

in c#

OpenStudy (anonymous):

private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { this.textBox1.Text = this.listBox1.SelectedValue.ToString(); if (listBox1.SelectedItem.Equals("Gearbox")) { string con = @"Server=(local);user id=sa;password=;database=TurnShop"; string qry = @"select * from Manufacturer where Product_type ='Gearbox'"; SqlDataAdapter cmd = new SqlDataAdapter(qry, con); DataSet ds = new DataSet(); cmd.Fill(ds, "Manufacturer"); this.dataGridView1.DataSource = ds; } else if (listBox1.SelectedItem.Equals("Brakes")) { string con = @"Server=(local);user id=sa;password=;database=TurnShop"; string qry = @"select * from Manufacturer where Product_type ='Brakes'"; SqlDataAdapter cmd = new SqlDataAdapter(qry, con); DataSet ds = new DataSet(); cmd.Fill(ds, "Manufacturer"); this.dataGridView1.DataSource = ds; } } This might solve it might

OpenStudy (appleduardo):

mm i already have two list boxes, and i want to know which ones of thoses are different to the other and then print the result

OpenStudy (anonymous):

try this Private Sub CommonFactors(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Common.Click Dim BoolAdd As Boolean, i As Double, j As Double BoolAdd = False ' lstFact1 & lstFact2 are the factor listboxes ' lstCommon is where the common factors are supposed to go If lstFact1.Items.Count = 0 Then Exit Sub ElseIf lstFact2.Items.Count = 0 Then Exit Sub Else For i = lstFact1.Items.Count - 1 To 0 Step -1 For j = 0 To lstFact2.Items.Count If lstFact1.Items(i) = lstFact2.Items(j) Then BoolAdd = True Exit For Else BoolAdd = False End If Next j If BoolAdd = True Then lstCommon.Items.Add(lstFact1.Items(i)) lstFact1.Items.Remove(i) lstFact2.Items.Remove(j) End If Next i End If End Sub

OpenStudy (appleduardo):

but in the code that you just sent me, what are the controls i have to add to enter the numbers i want to compare ??

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!