// This will hold the urls
private ObservableCollection<string> urls = new ObservableCollection<string>();
private void button_Click(object sender, RoutedEventArgs e)
{
// Parse the url from our text and add it to our collection
urls.Add(GetUrlFromText(textBox.Text));
dataGrid.ItemsSource = urls.Select(s => new { Urls = s });
}
1 回答
目前还不清楚DataGridView控件中可能包含的其他数据,但实现此目的的一种方法是将其绑定到包含要显示的Url的私有
BindingList<string>
. 然后,在从字符串中解析Url之后,您只需将其添加到BindingList
即可 .例如: