protected override void CommitProperties() { // Keep track of whether selectedIndex was programmatically changed var selectedIndexChanged = ProposedSelectedIndex != NO_PROPOSED_SELECTION; // If selectedIndex was set to CUSTOM_SELECTED_ITEM, and no selectedItem was specified, // then don't change the selectedIndex if (ProposedSelectedIndex == CUSTOM_SELECTED_ITEM && null == PendingSelectedItem) { ProposedSelectedIndex = NO_PROPOSED_SELECTION; } base.CommitProperties(); if (null != TextInput) { if (_maxCharsChanged) { TextInput.MaxChars = _maxChars; _maxCharsChanged = false; } if (_restrictChanged) { TextInput.Restrict = _restrict; _restrictChanged = false; } if (_typicalItemChanged) { if (TypicalItem != null) { var itemString = LabelUtil.ItemToLabel(TypicalItem, LabelField, LabelFunction); //TextInput.widthInChars = itemString.Length; } /*else * { * // Just set it back to the default value * //textInput.widthInChars = 10; * }*/ _typicalItemChanged = false; } // Clear the TextInput because we were programmatically set to NO_SELECTION // We call this after super.commitProperties because commitSelection might have // changed the value to NO_SELECTION if (selectedIndexChanged && SelectedIndex == NO_SELECTION) { TextInput.Text = string.Empty; } } }
protected override void UpdateLabelDisplay(object displayItem = null) { if (null == LabelDisplay) { return; } if (null == displayItem) { displayItem = SelectedItem; } LabelDisplay.Text = null != displayItem? LabelUtil.ItemToLabel(displayItem, LabelField, LabelFunction) : _prompt; }
protected override void UpdateLabelDisplay(object displayItem = null) { base.UpdateLabelDisplay(displayItem); if (null != TextInput) { if (null == displayItem) { displayItem = SelectedItem; } if (null != displayItem) { TextInput.Text = LabelUtil.ItemToLabel(displayItem, LabelField, LabelFunction); } } }
/** * Given a data item, return the correct text a renderer * should display while taking the <code>labelField</code> * and <code>labelFunction</code> properties into account. */ override public string ItemToLabel(object item) { return(LabelUtil.ItemToLabel(item, LabelField, LabelFunction)); }