using ButcherManage.BO;
|
|
using ButcherManage.BO.LocalBL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace ButcherManage.Utils
|
|
{
|
|
public static class ControlsUtil
|
|
{
|
|
public static void EBindComboBox<T>(this ComboBox box, Func<T, bool> SetSelectIndex = null, int top = 10, params string[] extendFields)
|
|
where T : BaseInfo, new()
|
|
{
|
|
box.DisplayMember = "Name";
|
|
box.ValueMember = "ID";
|
|
|
|
var list = BaseInfoBL.GetList<T>(top, extendFields: extendFields);
|
|
box.DataSource = list;
|
|
if (SetSelectIndex != null)
|
|
{
|
|
var idx = list.FindIndex(x => SetSelectIndex(x));
|
|
if (idx > 0)
|
|
box.SelectedIndex = idx;
|
|
}
|
|
box.Refresh();
|
|
}
|
|
}
|
|
}
|