با سلام
من به یک دراپ دان multi select احتیاج دارم چطوری در win form این داشته باشم.
از کامپوننت نمیخواهم استفاده کنم
Printable View
با سلام
من به یک دراپ دان multi select احتیاج دارم چطوری در win form این داشته باشم.
از کامپوننت نمیخواهم استفاده کنم
سلام مشکل من هم هست
خودت باید بنویسی
این یه نمونه ی آماده
https://www.codeproject.com/Articles...-as-a-Dropdown
سلام
از تولباکس اضاف کنید CheckBoxComboBox
using PresentationControls;using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public class Status
{
public Status(int id, string name) { _Id = id; _Name = name; }
private int _Id;
private string _Name;
public int Id { get { return _Id; } set { _Id = value; } }
public string Name { get { return _Name; } set { _Name = value; } }
/// <summary>
/// Now used to return the Name.
/// </summary>
/// <returns></returns>
public override string ToString() { return Name; }
}
public class StatusList : List<Status>
{
}
private StatusList _StatusList = new StatusList();
private ListSelectionWrapper<Status> StatusSelections;
private void Form1_Load(object sender, EventArgs e)
{
var xx = new UploadCenterEntities();
var x = new List<Status>();
foreach (var y in xx.Role.ToList())
{
x.Add(new Status(y.Id, y.TitleFa));
}
_StatusList.AddRange(x);
StatusSelections = new ListSelectionWrapper<Status>(_StatusList, "Name");
checkBoxComboBox1.DataSource = StatusSelections;
checkBoxComboBox1.DisplayMemberSingleItem = "Name";
checkBoxComboBox1.DisplayMember = "NameConcatenated";
checkBoxComboBox1.ValueMember = "Selected";
}
private void button1_Click(object sender, EventArgs e)
{
var gg = new List<string>();
foreach (var t in checkBoxComboBox1.CheckBoxItems)
{
if (t.Checked)
{
ObjectSelectionWrapper<Status> v = (ObjectSelectionWrapper<Status>)t.ComboBoxItem;
gg.Add(v.Name + ":" + v.Item.Id);
}
}
MessageBox.Show(string.Join(",", gg));
}
}
}
DevExpress , Telerik این کنترل رو دارند.
ممنون منتظرم
مثل یک combobox باهاش رفتار کنید
db.SetCommand("Select * From pezeshk");
DataSet ds = db.GetData();
db.exec();
checkedComboBoxEdit1.Properties.DataSource = ds.Tables[0];
checkedComboBoxEdit1.Properties.ValueMember = "id";
checkedComboBoxEdit1.Properties.DisplayMember = "pezeshk_name";
اینطوری میشه آیتم های چک خورده رو ID شون رو گرفت و انداخت توی یک آرایه مثلا
string drID = checkedComboBoxEdit1.Properties.GetCheckedItems(). ToString();
string[] str = Regex.Split(drID, ", ");
ممنونم:لبخندساده: