Lookupedit使用求助,跪求帮助
lookupEdit,绑定数据源后,无论选择哪一行数据,鼠标单击完之后,都是显示第一行数据,怎么都调整不好绑定数据源代码
#region//添加lookup数据源
Public_class.LookUpEdit_Tools.InitLookUpEdit(lookUpEdit_distributor,
new string[] { "en_name", "distributor" },
new string[] { "客户名称", "分销商" },
new int[] { 50, 80 },
dictionart_fxs, "en_name", "distributor", 5);
#endregion
使用的方法:
#region//初始化LookUpEdit控件 (加载数据表中的一列或多列,且显示下拉列标题,可以设置下拉列的宽度)
/// <summary>
/// 初始化LookUpEdit控件 (加载数据表中的一列或多列,且显示下拉列标题,可以设置下拉列的宽度)
/// </summary>
/// <param name="lookUpEdit">空间名称</param>
/// <param name="fields">下拉要显示的列</param>
/// <param name="captions">下拉要显示的列标题</param>
/// <param name="widths">下拉显示列的宽度如果null 宽度为系统默认 </param>
/// <param name="dt">绑定的数据表</param>
/// <param name="valueMember">绑定列</param>
/// <param name="displayMember">显示列</param>
/// <param name="dropDownRows">下拉最多显示个数 如果为0,显示全部</param>
public static void InitLookUpEdit(DevExpress.XtraEditors.LookUpEdit lookUpEdit,
string[] fields, string[] captions, int[] widths,
DataTable dt, string valueMember, string displayMember, int dropDownRows)
{
lookUpEdit.Properties.NullText = "---请选择---";
lookUpEdit.Properties.Columns.Clear();
if (fields.Length != captions.Length)
{
return;
}
for (int i = 0; i < fields.Length; i++)
{
if (widths != null)
{
if (fields.Length != widths.Length)
{
return;
}
lookUpEdit.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo(fields, widths, captions));
lookUpEdit.Properties.Columns.Visible = widths == 0 ? false : true;
}
else
{
lookUpEdit.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo(fields, captions));
}
lookUpEdit.Properties.Columns.Alignment = DevExpress.Utils.HorzAlignment.Center;
}
if (widths == null)
lookUpEdit.Properties.Columns.Visible = false;
lookUpEdit.Properties.DataSource = dt;
lookUpEdit.Properties.ValueMember = valueMember;
lookUpEdit.Properties.DisplayMember = displayMember;
lookUpEdit.Properties.ShowHeader = true;
lookUpEdit.Properties.ShowFooter = false;
if (dropDownRows == 0)
{
lookUpEdit.Properties.DropDownRows = dt.Rows.Count + 1;
}
else
{
lookUpEdit.Properties.DropDownRows = dt.Rows.Count > dropDownRows ? dropDownRows : dt.Rows.Count;
}
}
#endregion
页:
[1]