HOW I CAN WRITE URDU LANGUAGE IN TEXT BOX

CODING FOR JUST SIMPLE TRY

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{

if (e.KeyChar == 'a')
{
awrite();
}


public void awrite()
{
char aleph;
string word;
aleph = 'u0627';
word = aleph.ToString();
textBox1.Text = word;
}
}

BUT PROBLEM WITH THIS CODING IS THA IT WIRTES ALEPH WITH A LETTER TOO AND WHEN I PRESS A AGAIN IT DOESNT WIRTE ANY THING PLZZZZZZZZ HELP!!!!!!

Comments

  • Only problem I can see with this code is that you are overwriting the textbox with just the string value of word each time instead of:

    [code] textBox1.Text = word; [/code]

    You should have:

    [code] textBox1.Text = textBox1.Text + word; [/code]
    Or
    [code] textBox1.Text += word; [/code]

    If I understand you correctly, you are saying it still inputs the 'a' letter, though you don't want it to? if that is the case, simply omit it using substring:

    [code] Tlen = textBox1.Text.Length
    textBox1.Text = textBox1.Text.Substring(0, Tlen -1) + word; [/code]

    That's all I can think of, let me know if it's something else. Dai.


    ------------------------------------------
    Do or do not, there is no try. |
    ------------------------------------------
  • here is my modified coding

    private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
    {

    if (e.KeyChar == 'j')
    {
    jwrite();

    }

    if (e.KeyChar == 'm')
    {
    mwrite();

    }

    if (e.KeyChar == 's')
    {
    swrite();

    }

    if (e.KeyChar == 'u')
    {
    uwrite();

    }
    if (e.KeyChar == 'd')
    {
    dwrite();
    }

    e.Handled = true;
    }
    public void jwrite()
    {
    char jeem;
    string word;
    jeem= 'u062C';
    word = jeem.ToString();
    textBox1.Text += word;

    }

    public void mwrite()
    {

    char meem;
    string word;
    meem = 'u0645';
    word = meem.ToString();
    textBox1.Text += word;

    }
    public void swrite()
    {

    char shen;
    string word;
    shen = 'u0634';
    word = shen.ToString();
    textBox1.Text += word;
    }

    public void swrite()
    {

    char shen;
    string word;
    shen = 'u0634';
    word = shen.ToString();
    textBox1.Text += word;

    }
    public void dwrite()
    {
    char dal;
    dal = 'u062F';
    string word;
    word =dal.ToString();//+ ra.ToString()+dal.ToString()+ wao.ToString();

    textBox1.Text += word;
    }
    in this coding i have an other problem my cursor is not moving while writing text and i can't make editing in the text box i mean when i edit in text box it again insert seprate urdu charactor it doesn't append the charactor with the current text where i want so plssssssssssssss help!!!!!!!

  • Hi, sorry for the late reply, you've probably solved it by now but anyway, I got the same problem as you and fixed it by adding:
    [code] TextBox1.SelectionStart = TextBox1.Text.Length [/code]
    after the[red] textBox1.Text += word; [/red]line.
    ------------------------------------------
    Do or do not, there is no try. |
    ------------------------------------------
  • DAI AFTER HAVING TRY OF 6 DAYS I COUDN'T FIXED IT NOW THERE IS AN OTHER PROBLEM NOW THE CURSOR MOVES WHILE WRITTING ON IT BUT WHEN I HIT THE SPACE BAR THE CURSOR AGAIN MOVES IN THE END OF TEXT OF TEXTBOX AND WHEN I ENTER NEW CHARCTOR IN THE BETWEEN WORD IT APPENDS THAT CHARACTOR IN THE END OF WORD MY CODING IS GIVEN BELOW PLEASEEEEEEE HELP I GUESS IT'S ABOUT TO COMPLETE..BUT REQUIRES UR HELP

    private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
    {

    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.SelectionStart = textBox1.Text.Length;
    }


    //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;
    // int Tlen = textBox1.Text.Length;
    // textBox1.Text = textBox1.Text.Substring(0, Tlen - 1) + word;
    textBox1.SelectionStart = textBox1.Text.Length;


    }
    public void swrite()
    {

    char shen;
    string word;
    shen = 'u0634';
    word = shen.ToString();
    textBox1.Text += word;
    // int Tlen = textBox1.Text.Length;
    // textBox1.Text = textBox1.Text.Substring(0, Tlen - 1) + word;
    textBox1.SelectionStart = textBox1.Text.Length;


    }
    public void mwrite()
    {

    char meem;
    string word;
    meem = 'u0645';
    word = meem.ToString();
    textBox1.Text += word;
    //int Tlen = textBox1.Text.Length;
    // textBox1.Text = textBox1.Text.Substring(0, Tlen - 1) + word;
    textBox1.SelectionStart = textBox1.Text.Length;


    }

    public void jwrite()
    {
    char jeem;
    string word;
    jeem= 'u062C';
    word = jeem.ToString();
    textBox1.Text += word;
    int Tlen = textBox1.Text.Length;
    textBox1.Text = textBox1.Text.Substring(0, Tlen - 1) + word;
    textBox1.SelectionStart = textBox1.Text.Length;


    }
    public void awrite()
    {
    char aleph;
    string word;
    aleph = 'u0627';
    word = aleph.ToString();

    textBox1.Text += word;
    // int Tlen = textBox1.Text.Length;
    // textBox1.Text = textBox1.Text.Substring(0, Tlen - 1)+word;
    textBox1.SelectionStart = textBox1.Text.Length;



    }

    public void dwrite()
    {
    char dal;
    dal = 'u062F';
    string word;
    word =dal.ToString();

    textBox1.Text += word;
    // int Tlen = textBox1.Text.Length;
    textBox1.SelectionStart = textBox1.Text.Length;
    //textBox1.Text = textBox1.Text.Substring(0, Tlen - 1)+word;


    }
  • Hi, sorry it took so long for a reply, had to wipe pc and re-install everything. To overcome this problem, you need to simply split the string in 2 and add the text in right place. Here's the modified bits of code:

    First add these public variables:

    [code]
    public partial class Form1 : Form
    {
    string str1;
    string str2;
    int CursPos;
    [/code]

    Then change next part to:

    [code]
    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();

    }

    // Rest of code as normal until public void uwrite
    [/code]

    Then at public void uwrite:

    [code]
    public void uwrite()
    {
    char ye;
    string word;
    ye = 'u06CC';
    word = ye.ToString();
    textBox1.Text = str1 + word + str2;
    // int Tlen = textBox1.Text.Length;
    // textBox1.Text = textBox1.Text.Substring(0, Tlen - 1) + word;
    if (str2 == "")
    {
    textBox1.SelectionStart = textBox1.Text.Length;
    }
    else
    {
    textBox1.SelectionStart = CursPos;
    }
    }
    [/code]

    Apply above alteration to swrite, dwrite etc. You should find now that it works as intended, let me know either way. Dai.


    ------------------------------------------
    Do or do not, there is no try. |
    ------------------------------------------
  • when i am trying urdu in my project it is not joing all words like jamshaid is shown separately jeem sheen like this what is problem with it.here is my code
    private void button1_Click(object sender, EventArgs e)
    {
    char aleph ;
    char ra;
    char dal;
    char wao;
    string word;
    char jeem;
    jeem = 'u062C';
    char meem;
    meem = 'u0645';
    char shen;
    shen = 'u0634';
    aleph = 'u0627';
    ra = 'u0631';
    dal = 'u062F';
    wao = 'u0648';
    char ye;
    ye = 'u06CC';
    word = dal.ToString();
    word +=ye.ToString();
    word += shen.ToString();
    word += meem.ToString();
    word+=jeem.ToString();
    textBox1.Text = word;

    }
    public void jwrite()
    {
    char jeem;
    string word;
    jeem = 'u062C';
    word = jeem.ToString();
    textBox1.Text += word;

    }
  • when i am trying urdu in my project it is not joing all words like jamshaid is shown separately jeem sheen like this what is problem with it.here is my code
    private void button1_Click(object sender, EventArgs e)
    {
    char aleph ;
    char ra;
    char dal;
    char wao;
    string word;
    char jeem;
    jeem = 'u062C';
    char meem;
    meem = 'u0645';
    char shen;
    shen = 'u0634';
    aleph = 'u0627';
    ra = 'u0631';
    dal = 'u062F';
    wao = 'u0648';
    char ye;
    ye = 'u06CC';
    word = dal.ToString();
    word +=ye.ToString();
    word += shen.ToString();
    word += meem.ToString();
    word+=jeem.ToString();
    textBox1.Text = word;

    }
    public void jwrite()
    {
    char jeem;
    string word;
    jeem = 'u062C';
    word = jeem.ToString();
    textBox1.Text += word;

    }
  • So nice~I am a fun of c#.But I gave up later!
  • So nice~I am a fun of c#.But I gave up later!
  • So nice~I am a fun of c#.But I gave up later!
  • So nice~I am a fun of c#.But I gave up later!
  • musadiqmusadiq Pakistan

    JOB REQUIRED +923207197224

    https://www.sites.google.com/site/urdutextbox7/

    alos visit products page of my site for skill level : musadiq.brinkser.net

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories