ComboBoxItemCollection.Add(String, Object) Method
Adds an item to the combo box editor’s item collection.
Namespace: DevExpress.Blazor.Office
Assembly: DevExpress.Blazor.v24.1.dll
NuGet Package: DevExpress.Blazor
Declaration
public IBarComboBoxItem Add(
string text,
object value
)
Parameters
Name | Type | Description |
---|---|---|
text | String | The item text. |
value | Object | The item value. |
Returns
Type | Description |
---|---|
IBarComboBoxItem | The combo box item. |
Remarks
The following code snippet adds a custom combo box editor to the File group on the toolbar. The editor allows users to select an output file format for the document.
<DxRichEdit CustomizeToolbar=OnCustomizeToolbar BarMode=BarMode.Toolbar/>
@code {
void OnCustomizeToolbar(IToolbar toolbar) {
BarGroupCollection groups = toolbar.Groups;
groups.Clear();
AddFileCommonGroup(groups);
// ...
}
void AddFileCommonGroup(BarGroupCollection groups) {
IBarGroup fileCommonGroup = groups.Add(RichEditRibbonGroupNames.FileCommon);
// ...
// Adds a custom combo box
IBarComboBox documentFormatComboBox = fileCommonGroup.Items.AddCustomComboBox(2,
() => documentFormat,
(value) => Task.FromResult(documentFormat = (DocumentFormat)value)
);
documentFormatComboBox.Items.Add("Word Document (*.docx)", DocumentFormat.OpenXml);
documentFormatComboBox.Items.Add("Rich Text Format (*.rtf)", DocumentFormat.Rtf);
documentFormatComboBox.Items.Add("Plain Text (*.txt)", DocumentFormat.PlainText);
documentFormatComboBox.AllowUserInput = false;
documentFormatComboBox.CssClass = "document-format-combobox";
documentFormatComboBox.Tooltip = "Change file type.";
documentFormatComboBox.Text = "Save as type: ";
}
}
See Also