Hi, I have an UltraCombo bound to an UltraGrids cell. While the cell is multiline, my users can edit a good portion of text in the cell. When using the ultracombo the users can select a string from a list of strings. This string will be copied into the cell and the users can edit this text. Now - when the users tries to navigate through the edited text with the arrow keys, he actually navigates through the ultracombos entries and the edited text is replaced by the string selected from the combox in an instant. How can i prevent the ultracombo from scrolling through the rows when hitting arrow keys?
Thanks for all helpful answers.
Hi Martin,
Are you referring to the TextBox control that is in the DotNet Framework? If so, I think Microsoft would be a better source of information on that control.
As far as I know, the TextBox doesn't expose any properties to get the Visible lines, but I think there may be Windows API calls that will do it for you. If you want to pursue that, you should look into the SendMessage API.
Is there a way to get the "visible" lines in a textbox? I found fout, that TextBox.Lines returns the "real" lines - these with linefeeds. But I also can have a text without any linefeeds, but that is displayd with linefeeds - because it is to long to show it in one line. In this case that solution is not working.
Martin,
Honestly, I forgot about the up arrow but I see that you know have it all working!
Yeah, thats the solution i was looking for!
Actually, it was a bit tricky to find out the difference between up and down, but now i got it:
string[] lines = ((EditorWithText)(grdForecast.ActiveCell.EditorResolved)).TextBox.Lines;EmbeddableTextBox tb = ((EditorWithText)(grdForecast.ActiveCell.EditorResolved)).TextBox;int line = tb.GetLineFromCharIndex(tb.SelectionStart + tb.SelectionLength);if (e.KeyCode == Keys.Down) tb.SelectionStart += lines[line].Length + 2;else tb.SelectionStart -= lines[line-1].Length + 2;
Thanks for your help, Boris!
Oooh, now I get it! Could you please try the following code sample:
if (e.KeyCode == Keys.Down) { string[] lines = ((Infragistics.Win.UltraWinGrid.UltraGridComboEditor)(ultraGrid1.ActiveCell.EditorResolved)).TextBox.Lines; EmbeddableTextBox tb = ((Infragistics.Win.UltraWinGrid.UltraGridComboEditor)(ultraGrid1.ActiveCell.EditorResolved)).TextBox; int line = tb.GetLineFromCharIndex(tb.SelectionStart + tb.SelectionLength); tb.SelectionStart += lines[line].Length + 2; e.Handled = true; }