c# 4.0 - tab multiple selected lines of wpf textbox c# -
i facing problem text box control in wpf application. problem when user selects multilines of text , clicks on tab, selected lines deleted instead of being indented right. there way solve issue?
appreciate help. ahmad
you need handle in code behind not default action of textbox. many ways can handle it. need override previewkeydown , can set e.handled true in order text not overridden.
private void textbox_previewkeydown(object sender, system.windows.input.keyeventargs e) { textbox tbx = sender textbox; if (e.key == key.tab) { tbx.text = tbx.text.insert(tbx.selectionstart, "\t" + tbx.text.substring(tbx.selectionstart)); e.handled = true; } }
Comments
Post a Comment