Dual Data Combo Box
An enhanced combo box for displaying IDs and descriptions or only descriptions, with support for additional buttons and filter box.
Namespace: LSOne.Controls
Assembly: LSOne.Controls.DataControls
Syntax
public class DualDataComboBox : DropDownFormComboBox
Constructors
Name | Description |
---|---|
DualDataComboBox() | Default constructor |
Properties
Name | Description |
---|---|
AddList | Gets or sets the list of IDataEntity to be displayed |
AllowKeyboardSelection | Deprecated. |
AutoSelectOnEmpty |
Deprecated. Default value: true |
Checked |
The default state of the checkbox displayed in the combo box, if the checkbox is enabled through HasCheckBox property. Default value: false. Inherited from parent. |
ClientRectangle |
Gets the control bound's rectangle. Inherited from parent. |
Enabled |
If false it disables the control and also hides the checkbox if it was enabled through HasCheckBox property. Inherited from parent. |
EnableTextBox |
Gets or sets if text can be entered in the combobox. Default value: false. Inherited from parent. |
Font |
Gets or sets the text font. Inherited from parent. |
ForeColor |
Gets or sets the text color. Inherited from parent. |
HasCheckBox |
If true it will display a checkbox in the dropdown with its state set to the value of Checkbox property Inherited from parent. |
HorizontalScrollbar | Gets or sets if the displayed panel will contain horizontal scrollbar |
MaxLength |
Gets or sets the maximum number of characters the user can type or paste into the text box control. Default value: 32767 (short.MaxLength) Inherited from parent. |
MultiSelectEntity | Deprecated. |
NoChangeAllowed |
Gets or sets if a "No change" button will be displayed. The button selects a "no change" DataEntity based on NoChangeID property. Inherited from parent. |
NoChangeID | Gets a default GUID (a37f8082-0ecc-4d43-9876-65897363a5cf) for "no change" record. |
OnlyDisplayID | Gets or sets if only the ID column to be displayed. |
ReceiveKeyboardEvents |
Gets or sets if the control can be navigated using keyboard. Default value: false. Inherited from parent. |
RemoveList | Gets or sets the list of items to be removed from the control. |
RowHeight |
Gets or sets the height of each row from the dropdown panel. Default value: 22. Inherited from parent. |
SecondaryData | Inherited from parent. |
SelectedData | Gets or sets the selected DataEntity. |
SelectedDataID | Gets or sets the selected DataEntity ID if it exists or null. |
SelectionList | Gets or sets multiple selected DataEntities or null. |
SelectNoneAllowed | Inherited from parent. |
ShowDropDownOnTyping | Inherited from parent. |
SkipIDColumn | |
Text |
Gets or sets the text in the search box Inherited from parent. |
Touch |
Gets or sets if the control should be touch-friendly. Default value: false. |
UsesMasterDataEntity |
Gets or sets if the control uses MasterIDEntity or DataEntity objects. Default value: false. |
Methods
Name | Description |
---|---|
Clear() | Clears all data. |
CloseDropDown() |
Closes the dropdown panel. Inherited from parent. |
SendKey(IntPtr, uint, bool) |
Sends a keyboard key. Inherited from parent. |
SetData(IEnumerable<IDataEntity>, Image) | Set data. |
SetData(IEnumerable<IDataEntity>, Image, bool) | Set data. |
SetData(IEnumerable<IDataEntity>, Image, bool, List<RecordIdentifier>) | Set data. |
SetData(IEnumerable<IDataEntity>, Image, List<RecordIdentifier>) | Set data. |
SetData(IDataEntity[], IControlClosable) | Set data in the given panel. |
ShouldSerializeFont() |
Returns true if the control font is different than the search textbox font. Inherited from parent. |
ShouldSerializeText() |
Deprecated. Inherited from parent. |
ShowDropDown() |
Show the dropdown window. Inherited from parent. |
ShowDropDown(string) |
Show the dropdown window. Inherited from parent. |
TriggerSelectedDataChangedEvent() |
Triggers SelectedDataChanged event. Inherited from parent. |
Events
Name | Description |
---|---|
CheckedChanged |
Raised when the state of the control's checkbox has changed. Inherited from parent. |
DropDown |
Raised when the dropdown is shown. Inherited from parent. |
FormatData |
Raised when selection changes. Inherited from parent. |
GotFocus |
Raised when control gets the focus. Inherited from parent. |
LostFocus |
Raised when control losts its focus. Inherited from parent. |
PropertyChanged | Inherited from parent. |
RequestClear |
Raised when the search text is cleared. Inherited from parent. |
RequestData | Raised when dropdown is shown but no data is loaded in the control. |
SelectedDataChanged |
Raised when selection changed. Inherited from parent. |
SelectedDataCleared |
Raised when any selection was removed. Inherited from parent. |
Examples
See Source\SM\Plugins\BarCodes\Dialogs\BarCodeDialog.cs and Source\SM\Plugins\RetailItems\DialogPages\NewRetailItemGeneralPage.cs from DevPack for usage examples.
Getting data into the combo box
When the user presses the combo box, a RequestData event is fired. Within this event you need to fetch the data required and input it into the combo box through the function
SetData(IEnumerable<IDataEntity> data, ImageList imageList, int imageIndex)
Where data is usually a list of data entity, imageList is a list containing a list of images and imageIndex is the index to use from the list of images. The chosen image is displayed in front of each row.
If you do not wish to have any images you can simply input the image list as null.
private void cmbBarCodeSetup_RequestData(object sender, EventArgs e)
{
var barcodeSetups = Providers.BarCodeSetupData.GetList(PluginEntry.DataModel);
cmbBarCodeSetup.SetData(barcodeSetups, null);
}
You can also change the drop-down by embedding any control that implements IControlClosable like the following controls from the LSOne.Controls.DataControls assembly:
- TabbedDualDataPanel
- SingleSearchPanel
- DualDataPanel
- EmployeeSearchPanel
- MultiSearchPanel
- CheckBoxSelectionListPanel
private void cmbUnit_RequestData(object sender, EventArgs e)
{
if (salesUnitID == null)
{
salesUnitID = Providers.RetailItemData.GetItemUnitID(PluginEntry.DataModel, this.itemID, RetailItem.UnitTypeEnum.Sales);
}
IEnumerable<DataEntity>[] data = new IEnumerable<DataEntity>[]
{Providers.UnitConversionData.GetConvertableTo(PluginEntry.DataModel,itemID,salesUnitID),
Providers.UnitData.GetAllUnits(PluginEntry.DataModel).Cast<DataEntity>()};
TabbedDualDataPanel pnl = new TabbedDualDataPanel(
cmbUnit.SelectedData != null ? cmbUnit.SelectedData.ID : "",
data,
new string[] { Properties.Resources.Convertible, Properties.Resources.All },
250);
cmbUnit.SetData(data, pnl);
}
Clearing the data from the combo box
When the user presses the backspace button then the RequestClearevent is fired. Here you can place logic for the clearing the combo box.
private void cmbUnit_RequestClear(object sender, EventArgs e)
{
cmbUnit.SelectedData = new Unit("", "", 0, 0);
}
Retrieving selected data
You can get the selected entity by using the SelectedData property of the combo box or only the ID through SelectedData.ID or the selected text by using the Text property.
if (cmbUnit.SelectedData.ID != ""){
//do some logic
}
See also