codes
public partial class Form1 : Form
{
string str1;
string str2;
int CursPos;
public Form1()
{
InitializeComponent();
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (textBox1.SelectionStart < textBox1.Text.Length)
{
str1 = textBox1.Text.Substring(0, textBox1.SelectionStart);
str2 = textBox1.Text.Substring(textBox1.SelectionStart);
CursPos = textBox1.SelectionStart + 1;
}
else
{
str1 = textBox1.Text;
str2 = "";
}
if (e.KeyChar == 'a')
{
awrite();
}
if (e.KeyChar == 'd')
{
dwrite();
}
if (e.KeyChar == 'j')
{
jwrite();
}
if (e.KeyChar == 'm')
{
mwrite();
}
if (e.KeyChar == 's')
{
swrite();
}
if (e.KeyChar == 'u')
{
uwrite();
}
e.Handled = true;
if (e.KeyChar == (char)Keys.Space)
{
e.Handled = false;
textBox1.TextAlign = Left;
}
//char aleph ;
// string word;
//aleph = 'u0627';
/* char ra;
char dal;
char wao;
string word;
aleph = 'u0627';
ra = 'u0631';
dal = 'u062F';
wao = 'u0648';
* */
// word = aleph.ToString();//+ ra.ToString()+dal.ToString()+ wao.ToString();
// textBox1.Text = word;
}
public void uwrite()
{
char ye;
string word;
ye = 'u06CC';
word = ye.ToString();
textBox1.Text += word;
textBox1.Text = str1 + word + str2;
// int Tlen = textBox1.Text.Length;
// textBox1.Text = textBox1.Text.Substring(0, Tlen - 1) + word;
textBox1.SelectionStart = textBox1.Text.Length;
if (str2 == "")
{
textBox1.SelectionStart = textBox1.Text.Length;
}
else
{
textBox1.SelectionStart = CursPos;
}
}
public void swrite()
{
char shen;
string word;
shen = 'u0634';
word = shen.ToString();
textBox1.Text += word;
textBox1.Text = str1 + word + str2;
// int Tlen = textBox1.Text.Length;
// textBox1.Text = textBox1.Text.Substring(0, Tlen - 1) + word;
textBox1.SelectionStart = textBox1.Text.Length;
if (str2 == "")
{
textBox1.SelectionStart = textBox1.Text.Length;
}
else
{
textBox1.SelectionStart = CursPos;
}
}
public void mwrite()
{
char meem;
string word;
meem = 'u0645';
word = meem.ToString();
textBox1.Text += word;
textBox1.Text = str1 + word + str2;
//int Tlen = textBox1.Text.Length;
// textBox1.Text = textBox1.Text.Substring(0, Tlen - 1) + word;
textBox1.SelectionStart = textBox1.Text.Length;
if (str2 == "")
{
textBox1.SelectionStart = textBox1.Text.Length;
}
else
{
textBox1.SelectionStart = CursPos;
}
}
public void jwrite()
{
char jeem;
string word;
jeem= 'u062C';
word = jeem.ToString();
textBox1.Text += word;
textBox1.Text = str1 + word + str2;
// int Tlen = textBox1.Text.Length;
//textBox1.Text = textBox1.Text.Substring(0, Tlen - 1) + word;
textBox1.SelectionStart = textBox1.Text.Length;
if (str2 == "")
{
textBox1.SelectionStart = textBox1.Text.Length;
}
else
{
textBox1.SelectionStart = CursPos;
}
}
public void awrite()
{
char aleph;
string word;
aleph = 'u0627';
word = aleph.ToString();
textBox1.Text = str1 + word + str2;
textBox1.Text += word;
// int Tlen = textBox1.Text.Length;
// textBox1.Text = textBox1.Text.Substring(0, Tlen - 1)+word;
textBox1.SelectionStart = textBox1.Text.Length;
if (str2 == "")
{
textBox1.SelectionStart = textBox1.Text.Length;
}
else
{
textBox1.SelectionStart = CursPos;
}
}
public void dwrite()
{
char dal;
dal = 'u062F';
string word;
word =dal.ToString();
textBox1.Text += word;
textBox1.Text = str1 + word + str2;
// int Tlen = textBox1.Text.Length;
textBox1.SelectionStart = textBox1.Text.Length;
//textBox1.Text = textBox1.Text.Substring(0, Tlen - 1)+word;
if (str2 == "")
{
textBox1.SelectionStart = textBox1.Text.Length;
}
else
{
textBox1.SelectionStart = CursPos;
}
}
NOW PROBLEM WITH THIS CODE IS THAT WHEN I PRESS SPACE BAR CURSOR MOVES IN THE END OF TEXT IN THE TEXBOX AND I HAVE SET THE PROPERTY OF TEXTBOX ALIGHN AS RIGHT SO PLEASE HELP!!!!!!!!!