Hi muskesh009singh,
From your comment I'm assuming you want to do something like jumping in the text with special keyboard inputs. I created an example with an possible approach (maybe it's not exactly what you want, but I think you could adapt it - if you like it). Just copy to a C# 4 Forms project and replace Program.cs with the following code:
using System;
using System.Windows.Forms;
namespace NavigateToLetter
{
static class Program
{
[STAThread]
static void Main()
{
Form form = new Form();
form.Text = "NavigateToLetter";
TextBox textbox = new TextBox();
textbox.Multiline = true;
textbox.Dock = DockStyle.Fill;
form.Controls.Add(textbox);
textbox.PreviewKeyDown +=
delegate(object sender, PreviewKeyDownEventArgs e)
{
const int iF1_KEY = 112;
const int iF24_KEY = 135;
int iKey = (int)e.KeyCode;
if (iKey >= iF1_KEY &&
iKey <= iF24_KEY)
{
string strWord = String.Empty;
int iIndexOfLastSpace = textbox.Text.LastIndexOf(' ');
if (iIndexOfLastSpace < 0)
{
strWord = textbox.Text;
}
else
{
strWord = textbox.Text.Substring(iIndexOfLastSpace + 1);
}
if (!String.IsNullOrEmpty(strWord))
{
int iEnteredPosition = iKey - iF1_KEY;
if (strWord.Length >= iEnteredPosition)
{
int iNewPosition = textbox.Text.Length -
strWord.Length + iEnteredPosition;
textbox.Select(iNewPosition, 0);
}
}
}
};
Application.Run(form);
}
}
}