What is the simplest way to get the selected text of a combo box containing only text entries?

In your xml add SelectedValuePath=”Content” <ComboBox Name=”cboPickOne” SelectedValuePath=”Content” > <ComboBoxItem>This</ComboBoxItem> <ComboBoxItem>should be</ComboBoxItem> <ComboBoxItem>easier!</ComboBoxItem> </ComboBox> This way when you use .SelectedValue.ToString() in the C# code it will just get the string value without all the extra junk: stringValue = cboPickOne.SelectedValue.ToString()

How to get selected text from a textbox control with JavaScript

OK, here is the code I have: function ShowSelection() { var textComponent = document.getElementById(‘Editor’); var selectedText; if (textComponent.selectionStart !== undefined) { // Standards-compliant version var startPos = textComponent.selectionStart; var endPos = textComponent.selectionEnd; selectedText = textComponent.value.substring(startPos, endPos); } else if (document.selection !== undefined) { // Internet Explorer version textComponent.focus(); var sel = document.selection.createRange(); selectedText = sel.text; … Read more