[C#] 纯文本查看 复制代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace BaseFunction
{
/// <summary>
/// 处理一些控件的方法
/// </summary>
public class UI_Misc_Helper
{
/// <summary>
/// 返回选中的Comobox中Text对应的value值或者是value对应的Text值
/// </summary>
/// <param name="combobox">combobox对象</param>
/// <param name="dt_tables">要查询的表</param>
/// <param name="Text">要查询的字段</param>
/// <param name="Value">要返回的字段</param>
/// <returns>int</returns>
public static string GetComboBoxValueOrText(CRD.WinUI.Misc.ComboBox combobox, DataTable dt_tables, string Text, string Value)
{
//从dt_tables中查询出来Text对应是Value值
var result = dt_tables.AsEnumerable().Where(fi => fi[Text.ToString().Trim()].ToString().Trim()
== combobox.Text.ToString().Trim()).FirstOrDefault();
//把Value值返回
return result[Value.ToString().Trim()].ToString().Trim();
}
}
}
[C#] 纯文本查看 复制代码
string value=UI_Misc_Helper.GetComboBoxValueOrText(comboBox3, _dt_two, "uLogin", "uId");