You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

39 lines
982 B

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