有谁知道如何在 C# 中使字符串获取列表框特定(未选中)行的文本?我已经试过了(这有 itemselected):
string text = listBox1.SelectedItem.ToString();
string[] stringy = text.Split(' ');
MessageBox.Show(stringy[1]);
但这需要选择一个项目。如果可能的话,这就是我想要做的:
string text = listBox1.GetLine.ThatContainsText("stuff stuff stuff");
string[] stringy = text.Split(' ');
MessageBox.Show(string[1]);
如果有人能提供帮助,那就太好了。如果您需要我提供其他任何东西,我可以。
最佳答案
var textToSearchFor = "stuff stuff stuff";
var text = (from x in listBox1.Items.Cast<string>()
where x.Contains(textToSearchFor)
select x)
.FirstOrDefault(); //maybe even single, depending on your input
关于c# - 如何通过检查行是否包含特定文本来使字符串获取列表框特定行的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20010705/