Skip to content

Commit aa86b02

Browse files
authored
Merge pull request #2 from DuraimuruganVedagiri/master
WF-54532
2 parents 39eae29 + 7aff5e0 commit aa86b02

File tree

2 files changed

+43
-39
lines changed

2 files changed

+43
-39
lines changed

SfComboBox/SfComboBox/Form1.Designer.cs

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SfComboBox/SfComboBox/Form1.cs

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,34 @@ public Form1()
2020

2121
#region Events
2222

23-
int disableItemIndex = 1;
24-
2523
private void DropDownListView_SelectionChanged(object sender, Syncfusion.WinForms.ListView.Events.ItemSelectionChangedEventArgs e)
2624
{
27-
if (e.AddedItems.Count == this.sfComboBox1.DropDownListView.View.Items.Count())
25+
if (e.AddedItems.Count == this.sfComboBox.DropDownListView.View.Items.Count())
2826
{
29-
this.sfComboBox1.DropDownListView.CheckedItems.RemoveAt(disableItemIndex - 1);
27+
foreach (var value in disableItems)
28+
this.sfComboBox.DropDownListView.CheckedItems.Remove(value);
3029
}
3130
}
3231

3332
private void DropDownListView_ItemChecking(object sender, Syncfusion.WinForms.ListView.Events.ItemCheckingEventArgs e)
3433
{
35-
if(e.ItemIndex == disableItemIndex)
34+
bool isDisabledItem = disableItems.Contains(e.ItemData);
35+
if ((this.sfComboBox.AllowSelectAll == false && isDisabledItem) || (e.ItemIndex != 0 && isDisabledItem))
3636
{
3737
e.Cancel = true;
3838
}
3939
}
4040

41+
private void DropDownListView_SelectionChanging(object sender, Syncfusion.WinForms.ListView.Events.ItemSelectionChangingEventArgs e)
42+
{
43+
if (this.disableItems.Contains(e.AddedItems[0]))
44+
e.Cancel = true;
45+
}
46+
4147
private void DropDownListView_DrawItem(object sender, Syncfusion.WinForms.ListView.Events.DrawItemEventArgs e)
4248
{
43-
if (e.ItemIndex == disableItemIndex)
49+
bool isDisabledItem = disableItems.Contains(e.ItemData);
50+
if ((this.sfComboBox.AllowSelectAll == false && isDisabledItem) || (e.ItemIndex != 0 && isDisabledItem))
4451
{
4552
e.Style.BackColor = Color.LightGray;
4653
e.Style.ForeColor = Color.Gray;
@@ -51,24 +58,21 @@ private void DropDownListView_DrawItem(object sender, Syncfusion.WinForms.ListVi
5158

5259
#region Data Setting
5360

54-
public class Details
55-
{
56-
public string Name { get; set; }
57-
}
61+
List<string> disableItems = new List<string>() { "Asif" };
5862

59-
public List<Details> GetData()
63+
public List<string> GetData()
6064
{
61-
List<Details> list = new List<Details>();
62-
list.Add(new Details() { Name = "Amir"});
63-
list.Add(new Details() { Name = "Asif"});
64-
list.Add(new Details() { Name = "Catherine"});
65-
list.Add(new Details() { Name = "Cindrella"});
66-
list.Add(new Details() { Name = "David"});
67-
list.Add(new Details() { Name = "Ellis"});
68-
list.Add(new Details() { Name = "Farooq"});
69-
list.Add(new Details() { Name = "Muhammad"});
70-
list.Add(new Details() { Name = "Saleem"});
71-
list.Add(new Details() { Name = "Usman"});
65+
List<string> list = new List<string>();
66+
list.Add("Amir");
67+
list.Add("Asif");
68+
list.Add("Catherine");
69+
list.Add("Cindrella");
70+
list.Add("David");
71+
list.Add("Ellis");
72+
list.Add("Farooq");
73+
list.Add("Muhammad");
74+
list.Add("Saleem");
75+
list.Add("Usman");
7276
return list;
7377
}
7478

0 commit comments

Comments
 (0)