Skip to content

Commit

Permalink
update chip
Browse files Browse the repository at this point in the history
  • Loading branch information
JFriel committed Feb 13, 2025
1 parent 6808caf commit 341b13e
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,21 @@ public string Value
get => _value;
set
{
_value = value;
flowLayoutPanel1.Controls.Clear();
var splitValues = _value.Split(',');
comboBox1.Items.Clear();
comboBox1.Format += comboBox1_Format;
foreach (var option in _options.Where(o => !splitValues.Contains(o)).ToList())
{
comboBox1.Items.Add(option);
}
foreach (var splitValue in splitValues.Where(sv => !string.IsNullOrWhiteSpace(sv)))
if (_value != value)
{
_value = value;
flowLayoutPanel1.Controls.Clear();
var splitValues = _value.Split(',');
comboBox1.Items.Clear();
comboBox1.Format += comboBox1_Format;
foreach (var option in _options.Where(o => !splitValues.Contains(o)).ToList())
{
comboBox1.Items.Add(option);
}
foreach (var splitValue in splitValues.Where(sv => !string.IsNullOrWhiteSpace(sv)))
{
flowLayoutPanel1.Controls.Add(new Chip(splitValue, Remove));
}
}
}
}
Expand All @@ -75,7 +78,8 @@ public String[] Options

private int Remove(string value)
{
Value = string.Join(',', Value.Split(",").Where(v => v != value));
var valueToReplace = value.Replace(" ", "");
Value = string.Join(',', Value.Split(",").Where(v => v != valueToReplace));
return 1;
}

Expand Down

0 comments on commit 341b13e

Please sign in to comment.