|
|
@ -18,15 +18,24 @@ namespace BWP.WinFormControl |
|
|
this.DropDown += (sender, de) => |
|
|
this.DropDown += (sender, de) => |
|
|
{ |
|
|
{ |
|
|
CRefreshItems(); |
|
|
CRefreshItems(); |
|
|
//if (string.IsNullOrEmpty(this.Text))
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(this.Text)) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
//if (_enableTopItem && Items.Count > 1)
|
|
|
|
|
|
// this.SelectedIndex = 1;
|
|
|
|
|
|
//else if (!_enableTopItem && Items.Count > 0)
|
|
|
|
|
|
// this.SelectedIndex = 0;
|
|
|
|
|
|
|
|
|
if (_enableTopItem && Items.Count > 1) |
|
|
|
|
|
this.SelectedIndex = 1; |
|
|
|
|
|
else if (!_enableTopItem && Items.Count > 0) |
|
|
|
|
|
this.SelectedIndex = 0; |
|
|
SelectionStart = Text.Length; |
|
|
SelectionStart = Text.Length; |
|
|
}; |
|
|
}; |
|
|
|
|
|
this.SelectedIndexChanged += (sender, e) => |
|
|
|
|
|
{ |
|
|
|
|
|
var item = SelectedItem as WordPair; |
|
|
|
|
|
if (item.DisplayName == string.Empty) |
|
|
|
|
|
_selectedObj = null; |
|
|
|
|
|
else |
|
|
|
|
|
_selectedObj = item; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
this.DrawMode = DrawMode.OwnerDrawFixed; |
|
|
this.DrawMode = DrawMode.OwnerDrawFixed; |
|
|
this.DrawItem += new DrawItemEventHandler(cb_DrawItem); |
|
|
this.DrawItem += new DrawItemEventHandler(cb_DrawItem); |
|
|
this.DropDownClosed += new EventHandler(cb_DropDownClosed); |
|
|
this.DropDownClosed += new EventHandler(cb_DropDownClosed); |
|
|
@ -90,23 +99,10 @@ namespace BWP.WinFormControl |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private new WordPair SelectedValue |
|
|
|
|
|
{ |
|
|
|
|
|
get |
|
|
|
|
|
{ |
|
|
|
|
|
if (this.SelectedItem == null) |
|
|
|
|
|
return null; |
|
|
|
|
|
var result = this.SelectedItem as WordPair; |
|
|
|
|
|
if (string.IsNullOrEmpty(result.PhyName) && string.IsNullOrEmpty(result.DisplayName)) |
|
|
|
|
|
return null; |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CRefreshItems() |
|
|
void CRefreshItems() |
|
|
{ |
|
|
{ |
|
|
var inputArgs = string.Empty; |
|
|
var inputArgs = string.Empty; |
|
|
if (this.SelectedValue == null) |
|
|
|
|
|
|
|
|
if (this.SelectedItem == null) |
|
|
inputArgs = this.Text; |
|
|
inputArgs = this.Text; |
|
|
var list = ComboBoxHelper.GetList(rpcPath, inputArgs, CodeArgs, Range); |
|
|
var list = ComboBoxHelper.GetList(rpcPath, inputArgs, CodeArgs, Range); |
|
|
if (_enableTopItem) |
|
|
if (_enableTopItem) |
|
|
@ -118,58 +114,44 @@ namespace BWP.WinFormControl |
|
|
this.ValueMember = "PhyName"; |
|
|
this.ValueMember = "PhyName"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void Fill(string displayValue, string phyValue) |
|
|
|
|
|
{ |
|
|
|
|
|
this.SelectedText = displayValue; |
|
|
|
|
|
|
|
|
|
|
|
this.SelectedItem = new WordPair(displayValue, phyValue); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void Clear() |
|
|
public void Clear() |
|
|
{ |
|
|
{ |
|
|
this.Text = null; |
|
|
|
|
|
this.SelectedText = null; |
|
|
|
|
|
this.SelectedItem = null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public bool IsEmpty |
|
|
|
|
|
{ |
|
|
|
|
|
get { return SelectedValue == null; } |
|
|
|
|
|
|
|
|
_selectedObj = null; |
|
|
|
|
|
this.Text = string.Empty; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public string DisplayValue |
|
|
|
|
|
|
|
|
public void Fill(string display, string value) |
|
|
{ |
|
|
{ |
|
|
get |
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(display)) |
|
|
{ |
|
|
{ |
|
|
if (SelectedValue == null) |
|
|
|
|
|
return string.Empty; |
|
|
|
|
|
return SelectedValue.DisplayName; |
|
|
|
|
|
|
|
|
Clear(); |
|
|
|
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
_selectedObj = new WordPair(display, value); |
|
|
|
|
|
this.Text = display == null ? string.Empty : display; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public string Value |
|
|
|
|
|
{ |
|
|
|
|
|
get |
|
|
|
|
|
{ |
|
|
|
|
|
if (SelectedValue == null) |
|
|
|
|
|
return string.Empty; |
|
|
|
|
|
return SelectedValue.PhyName; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public bool IsEmpty { get { return _selectedObj == null; } } |
|
|
|
|
|
|
|
|
|
|
|
public string DisplayValue { get { if (IsEmpty) return null; return _selectedObj.DisplayName; } } |
|
|
|
|
|
|
|
|
|
|
|
public string Value { get { if (IsEmpty) return null; return _selectedObj.PhyName; } } |
|
|
|
|
|
|
|
|
public long? LongValue |
|
|
public long? LongValue |
|
|
{ |
|
|
{ |
|
|
get |
|
|
get |
|
|
{ |
|
|
{ |
|
|
if (SelectedValue == null) |
|
|
|
|
|
|
|
|
if (IsEmpty) |
|
|
return null; |
|
|
return null; |
|
|
long v; |
|
|
long v; |
|
|
if (long.TryParse(SelectedValue.PhyName, out v)) |
|
|
|
|
|
|
|
|
if (long.TryParse(_selectedObj.PhyName, out v)) |
|
|
return v; |
|
|
return v; |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private WordPair _selectedObj = new WordPair(); |
|
|
|
|
|
|
|
|
protected override void OnDropDown(EventArgs e) |
|
|
protected override void OnDropDown(EventArgs e) |
|
|
{ |
|
|
{ |
|
|
base.OnDropDown(e); |
|
|
base.OnDropDown(e); |
|
|
|