मैंने दो रेडियोबटन (वजन और ऊंचाई) बनाया। मैं दो श्रेणियों के बीच स्विच करूँगा। लेकिन वे एक ही सूची बॉक्स नियंत्रक (सूची बॉक्स 1 और सूची बॉक्स 2) साझा करते हैं।सभी सूची बॉक्स आइटम कैसे निकालें?
सभी ListBox आइटम सरल स्पष्ट करने के लिए किसी भी अच्छे पद्धति है? मुझे ListBox के लिए removeAll() नहीं मिला। मुझे अपनी जटिल बहु-रेखा शैली पसंद नहीं है जिसे मैंने यहां पोस्ट किया था।
private void Weight_Click(object sender, RoutedEventArgs e)
{
// switch between the radioButton "Weith" and "Height"
// Clear all the items first
listBox1.Items.Remove("foot");
listBox1.Items.Remove("inch");
listBox1.Items.Remove("meter");
listBox2.Items.Remove("foot");
listBox2.Items.Remove("inch");
listBox2.Items.Remove("meter");
// Add source units items for listBox1
listBox1.Items.Add("kilogram");
listBox1.Items.Add("pound");
// Add target units items for listBox2
listBox2.Items.Add("kilogram");
listBox2.Items.Add("pound");
}
private void Height_Click(object sender, RoutedEventArgs e)
{
// switch between the radioButton "Weith" and "Height"
// Clear all the items first
listBox1.Items.Remove("kilogram");
listBox1.Items.Remove("pound");
listBox2.Items.Remove("kilogram");
listBox2.Items.Remove("pound");
// Add source units items for listBox1
listBox1.Items.Add("foot");
listBox1.Items.Add("inch");
listBox1.Items.Add("meter");
// Add target units items for listBox2
listBox2.Items.Add("foot");
listBox2.Items.Add("inch");
listBox2.Items.Add("meter");
}
मैं मैट Dearing के एक बहुत जवाब पसंद है। यह केवल विशिष्ट आइटमों की तुलना में, इस विशिष्ट उपयोग के लिए बेहतर प्रोग्रामिंग तकनीक की तरह दिखता है। क्लीयर() विधि। –