Click here to Skip to main content
15,907,913 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

In single textbox, i want to set different forecolor and there alignment for different value.
For this i want to use custom control of textbox how can i set diffrent forecolor and there alignment for different value.

Please help me.

Thanks in Advance.
Posted
Updated 12-Jun-11 20:24pm
v4

I dont think you need to use a custom control just for this much.
Try and change the Forecolor and the TexAlign property.
 
Share this answer
 
v2
Hope this[^] might help you.
 
Share this answer
 
thanks for reply
i alredy done this but i want to build custom controll for this
plzz help me
 
Share this answer
 
v3
Comments
parmar_punit 13-Jun-11 5:35am    
see my solution it will helpful to you...
C#
textBox1.ForeColor = Color.Pink;
textBox1.Text= "   " + textBox1.Text; // 3 space for alignment value 3 and  4 space for alignment value 4 and so on...



Thanks,
Mamun
 
Share this answer
 
v2
I think for that you need rich textbox control
Example :
public void CreateMyRichTextBox()
{
    RichTextBox richTextBox1 = new RichTextBox();
    richTextBox1.Dock = DockStyle.Fill;

    richTextBox1.LoadFile("C:\\MyDocument.rtf");
    richTextBox1.Find("Text", RichTextBoxFinds.MatchCase);
    richTextBox1.SelectionFont = new Font("Verdana", 12, FontStyle.Bold);
    richTextBox1.SelectionColor = Color.Red;
    richTextBox1.SaveFile("C:\\MyDocument.rtf", RichTextBoxStreamType.RichText);
    this.Controls.Add(richTextBox1);
}

and for more details see the links that is listed below...
Link1[^]
Link2[^]
Link3[^]
 
Share this answer
 
thanks but
i think u r not understanding my problem
the condition to builde custom controll is
set 3 type of default text property
1. default text
2. default text forecolor
3. default text alignment

and same for current text property

when form is load default property is worked and hide the default property
i.e. default text is "Insert Name"
,alignment = center
,forecolor= blue

when textbox got focus current text property is worked
i.e. current text is ""
,alignment = left
,forecolor= black


i done this directlly in text Enter and Leave event
but i want this type of textbox in various forms
so i want to build customControll(CustomTextbox)
 
Share this answer
 
v2
Comments
parmar_punit 13-Jun-11 6:13am    
ok so you want something like watermark that guide the user??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900