Windows form yapıyorum, içinde bazı metin dosyaları okudum, bir combobox ve ne var Ben istiyorum combobox içinde "Oyunlar" seçeneğini seçtiğimde, richtextbox2 için "game.txt" okuma dosyasında bulunan metnin doldurulmasıdır. Ve diğer seçenekler ve metin dosyaları için de aynı. Bu ifadeyi denedim ama "dizeyi boole dönüştüremiyorum" şeklinde bir hata alıyorum. bir değer ==
operatörünü kullanmak gerekir başka eşitse C#Metin Kutusu, Visual Studio'da Windows Bileşeninden Seçimi Seçtikten Sonra Nasıl Yapılır Kutu Penceresi C#
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void richTextBox2_TextChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
//Fill combobox with names.
comboBox1.Items.Add("Games");
comboBox1.Items.Add("Operating");
comboBox1.Items.Add("Information");
try
{
//read text from text files.
string game = File.ReadAllText(@"game.txt");
string operate = File.ReadAllText(@"operate.txt");
string information = File.ReadAllText(@"info.txt");
//if you select Games option in combobox, fill text box with text from read file "game.txt".
if (comboBox1.Text = "Games")
{
richTextBox2.Text = game;
}
}
catch (Exception ex)
{
//display error if files not found.
MessageBox.Show(" " + ex.Message);
}
da Sorunu düzelttikten nasıl bir açıklama ekleyiniz ve: program çalışmalarını yapmak için bunu böyle bakabilir, senin
ComboBox
aitSelectedChangedIndex
içintry/catch
blok taşımak gerekir beklendiği gibi ne yapıyorsun. Kod sadece bazı okuyucular için kafa karıştırıcı olabilir –Tamam, tavsiye için teşekkürler .. – mvlttna