[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

allow user edit format string

bbla32

8/15/2008 5:10:00 PM

Hey, is there a fast way to change a string used for formatting, like

Value:\t{0}\r\n

to string that user can edit, like:

Value:\\t{0}\\r\\n

In other words, I want user to be able to edit a format string. Is
there a quicker way than

format.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\t"). ....
3 Answers

Family Tree Mike

8/15/2008 7:04:00 PM

0

I guess you lost me. Why is the second string easier for the user to edit?

If you ask the user for a formatting string from a textbox, then you just
use it like any other formatting string.

"bbla32@op.pl" wrote:

> Hey, is there a fast way to change a string used for formatting, like
>
> Value:\t{0}\r\n
>
> to string that user can edit, like:
>
> Value:\\t{0}\\r\\n
>
> In other words, I want user to be able to edit a format string. Is
> there a quicker way than
>
> format.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "> \t"). ....
>

bbla32

8/15/2008 8:16:00 PM

0

On Aug 15, 9:04 pm, Family Tree Mike
<FamilyTreeM...@discussions.microsoft.com> wrote:
> I guess you lost me.  Why is the second string easier for the user to edit?
>
> If you ask the user for a formatting string from a textbox, then you just
> use it like any other formatting string.

Let me give an example.
formatString = "{0}\n";
Console.Write(string.Format(formatString, 1)); // prints "1" and
newline.
// now let user edit it...
textBox1.Text = formatString; // it displays "{0}" followed by a box,
because it cannot display the newline character \n.
// I wish the user sees "{0}\n", so textBox1.Text should contain "{0}\n", which should be converted back to "{0}\n" after editing.

Family Tree Mike

8/16/2008 12:47:00 AM

0

Now I got what your doing. I don't see any way except for showing two
slashes in the text box and replacing on use as you did.

<bbla32@op.pl> wrote in message
news:8dfbdeaf-2a5d-4986-9a92-1be9013b221f@a1g2000hsb.googlegroups.com...
On Aug 15, 9:04 pm, Family Tree Mike
<FamilyTreeM...@discussions.microsoft.com> wrote:
> I guess you lost me. Why is the second string easier for the user to edit?
>
> If you ask the user for a formatting string from a textbox, then you just
> use it like any other formatting string.

Let me give an example.
formatString = "{0}\n";
Console.Write(string.Format(formatString, 1)); // prints "1" and
newline.
// now let user edit it...
textBox1.Text = formatString; // it displays "{0}" followed by a box,
because it cannot display the newline character \n.
// I wish the user sees "{0}\n", so textBox1.Text should contain "{0}\n", which should be converted back to "{0}\n" after editing.