c# 组合框有一个数据源,如何让它显示特定元素? [英] c# combobox has a datasource, how do i make it display a specific element?
本文介绍了c# 组合框有一个数据源,如何让它显示特定元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数据表作为组合框的来源:
i have a datatable as the source of a combobox:
1
3
2
4
5
不知道数据表中元素的顺序,只知道确切的文本,是否有可能显示像'4
'这样的特定元素?
without knowing the order of the elemnts inside the datatable, and only knowing the exact text, is it possible to display a specific element like '4
' ?
推荐答案
所以你应该这样做:
comboBox1.Text = "4";
或更改DataTable中相关字段的值:
or change the value of related field in DataTable:
((MyDataRowType)((DataRowView)bindingSource1.Current).Row).myFieldName = "4";
这篇关于c# 组合框有一个数据源,如何让它显示特定元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文