hi,
I want to get the value stored at integer array displayed on the textbox on selecting the itembox item i.e. the position of integer array element changes with change in itembox item index.
How to do this ?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Datta KharadRank #2,135 · 668 reputationPosted Nov 18, 2011, 9:23 PM EST
You can use this code for your above problem..
int[] arrPriceList; //Declare array
private void Form1_Load(object sender, EventArgs e)
{
//Initialize array with given value
arrPriceList = new int[] { 25000, 85000, 65000, 40000, 70000 };
//Add cars into listbox
listBox1.Items.AddRange(new object[] { "MARUTI", "INDICA", "SCODA", "SHIFT", "CIVIC" });
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
textBox3.Text = (arrPriceList[listBox1.SelectedIndex]).ToString();
}
//You will get price according to selected car.
Javeed M ShaikhRank #839 · 2.7K reputationPosted Nov 16, 2011, 5:24 PM EST
I am not clear of the requirements can you please explain with an example.
Manoj Singh PanwarRank #529 · 4.6K reputationPosted Nov 18, 2011, 8:16 PM EST
Now how to bind these two things?
Manoj Singh PanwarRank #529 · 4.6K reputationPosted Nov 21, 2011, 8:28 AM EST
Datta KharadRank #2,135 · 668 reputationPosted Nov 22, 2011, 8:33 PM EST
If your query resolved then mark as Correct Answer.