13 Replies - 5362 Views - Last Post: 09 October 2009 - 10:50 PM Rate Topic: -----

#1 avirag  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 92
  • Joined: 29-June 09

New Line on pressing Enter key

Posted 09 October 2009 - 02:56 AM

I made a window application in which whatever i write in the textbox that appears simultaneously in the picture box.
Also i have done the coding in such a way that when i use double backslash(\\) in text box then it automatically moves to new line in the picture box .
Now the problem is that i don't want to display the double slash in the text box, i want that when i press enter key then in the back end coding it should implement double backslash(\\) and moves to the new line in the picture box without displaying backslash in the text Box.
Can anyone help me in this............

Is This A Good Question/Topic? 1
  • +

Replies To: New Line on pressing Enter key

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: New Line on pressing Enter key

Posted 09 October 2009 - 03:23 AM

You need To make sure the textbox has it's Multiline property set to true.
Was This Post Helpful? 0
  • +
  • -

#3 avirag  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 92
  • Joined: 29-June 09

Re: New Line on pressing Enter key

Posted 09 October 2009 - 03:34 AM

View Posteclipsed4utoo, on 9 Oct, 2009 - 02:23 AM, said:

You need To make sure the textbox has it's Multiline property set to true.

Yes its already true............
In textbox it will come in next line, but not come in picturebox.
Kindly help me related to this.

This post has been edited by avirag: 09 October 2009 - 03:51 AM

Was This Post Helpful? 1
  • +
  • -

#4 avirag  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 92
  • Joined: 29-June 09

Re: New Line on pressing Enter key

Posted 09 October 2009 - 04:49 AM

Can anyone reply me related to my problem....................
Was This Post Helpful? 1
  • +
  • -

#5 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: New Line on pressing Enter key

Posted 09 October 2009 - 04:55 AM

can you post your code? It's kinda hard to understand your issue. Is it that the textbox isn't accepting a new line? or the Picture box isn't showing the new line?
Was This Post Helpful? 0
  • +
  • -

#6 avirag  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 92
  • Joined: 29-June 09

Re: New Line on pressing Enter key

Posted 09 October 2009 - 05:08 AM

View Posteclipsed4utoo, on 9 Oct, 2009 - 03:55 AM, said:

can you post your code? It's kinda hard to understand your issue. Is it that the textbox isn't accepting a new line? or the Picture box isn't showing the new line?


Well i m using Letex/mimeTex to convert the text of textbox in math format And the math output is display in a picturebox.
And according to Letex "\\" means new line.It means that whenever the user writes "\\", it gives a new line in picturebox,So i want that when the user presses enter key, it should show new line in picturebox as it gives in multiline textbox.
Was This Post Helpful? 0
  • +
  • -

#7 magius96  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 71
  • View blog
  • Posts: 777
  • Joined: 15-April 09

Re: New Line on pressing Enter key

Posted 09 October 2009 - 05:28 AM

Here's a theoretical approach. The textbox has an event for when the enter key is pressed. Intercept that event and use it to manually add the newline to both the text box and the picture box.
Was This Post Helpful? 0
  • +
  • -

#8 avirag  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 92
  • Joined: 29-June 09

Re: New Line on pressing Enter key

Posted 09 October 2009 - 05:36 AM

View Postmagius96, on 9 Oct, 2009 - 04:28 AM, said:

Here's a theoretical approach. The textbox has an event for when the enter key is pressed. Intercept that event and use it to manually add the newline to both the text box and the picture box.

Can you please tell me the name of that textbox event..........
Was This Post Helpful? 0
  • +
  • -

#9 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: New Line on pressing Enter key

Posted 09 October 2009 - 05:39 AM

View Postavirag, on 9 Oct, 2009 - 08:08 AM, said:

View Posteclipsed4utoo, on 9 Oct, 2009 - 03:55 AM, said:

can you post your code? It's kinda hard to understand your issue. Is it that the textbox isn't accepting a new line? or the Picture box isn't showing the new line?


Well i m using Letex/mimeTex to convert the text of textbox in math format And the math output is display in a picturebox.
And according to Letex "\\" means new line.It means that whenever the user writes "\\", it gives a new line in picturebox,So i want that when the user presses enter key, it should show new line in picturebox as it gives in multiline textbox.


You can use the Key_Up event for the textbox and catch when the key is the Enter key. Then send "//" to the "equation" instead of the enter key..

private void mtxtContactPhone_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Enter)
    {
        SendToLetex(@"\\");
    }
}


Was This Post Helpful? 0
  • +
  • -

#10 avirag  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 92
  • Joined: 29-June 09

Re: New Line on pressing Enter key

Posted 09 October 2009 - 05:47 AM

You can use the Key_Up event for the textbox and catch when the key is the Enter key. Then send "//" to the "equation" instead of the enter key..

private void mtxtContactPhone_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Enter)
    {
        SendToLetex(@"\\");
    }
}


[/quote]
Well i m using the below code, but its not showing any output......
private void textBox1_KeyDown(object sender, KeyEventArgs e)
		{
			
			if (e.KeyCode == Keys.Enter)
			{
				 FormatText("\\\\");
			}
}


private string FormatText(string input)
		{
	  input = input.Replace("\\\\", "\\\\");
	return input;
		}

	

	private void Form1_Load(object sender, System.EventArgs e)
		{
			this.textBox1.Focus();
		WriteEquation(FormatText(textBox1.Text));
			
		}


Kindly help me in this..........
Was This Post Helpful? 0
  • +
  • -

#11 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: New Line on pressing Enter key

Posted 09 October 2009 - 05:53 AM

oh...so you aren't doing it character by character, you are doing everything in the textbox each time.

Ok, so when you send the text to the WriteEquation method, you will need to replace the carriage return with "\\"..

WriteEquation(textBox1.Text.Replace("\r\n", @"\\");



So you don't need to use the Key_Down event after all.
Was This Post Helpful? 1
  • +
  • -

#12 avirag  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 92
  • Joined: 29-June 09

Re: New Line on pressing Enter key

Posted 09 October 2009 - 06:08 AM

View Posteclipsed4utoo, on 9 Oct, 2009 - 04:53 AM, said:

oh...so you aren't doing it character by character, you are doing everything in the textbox each time.

Ok, so when you send the text to the WriteEquation method, you will need to replace the carriage return with "\\"..

WriteEquation(textBox1.Text.Replace("\r\n", @"\\");



So you don't need to use the Key_Down event after all.


Thanks for your reply, it works.............. :)
Was This Post Helpful? 0
  • +
  • -

#13 avirag  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 92
  • Joined: 29-June 09

Re: New Line on pressing Enter key

Posted 09 October 2009 - 06:35 AM

View Posteclipsed4utoo, on 9 Oct, 2009 - 04:53 AM, said:

oh...so you aren't doing it character by character, you are doing everything in the textbox each time.

Ok, so when you send the text to the WriteEquation method, you will need to replace the carriage return with "\\"..

WriteEquation(textBox1.Text.Replace("\r\n", @"\\");



So you don't need to use the Key_Down event after all.

Hi i have one more problem related to this.......
I am using the below code to unable only one space between the characters in the textBox, but in my code when user uses left arrow key, then he is able to use spacebar key more than once between characters.....
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
		{
			TextBox tb = (TextBox)sender;
			if ((e.KeyChar == ' ') && (tb.Text.Length > 0))
				{
					if (tb.Text[tb.Text.Length - 1] == ' ')
					e.Handled = true;
				}
		   
		}


But i want that when the user presses left arrow key, in that case also user should not able to use the spacebar key more than once......
Kindly help me in this.......

This post has been edited by avirag: 09 October 2009 - 06:36 AM

Was This Post Helpful? 0
  • +
  • -

#14 avirag  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 92
  • Joined: 29-June 09

Re: New Line on pressing Enter key

Posted 09 October 2009 - 10:50 PM

Can anyone help me related to this.......... ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1