textbox control with multi colored rows
-
I wanted a multiline textbox control with possibility of giving different background colors to the lines. for eg:- if the first line has a white background the second line should have a yellow background etc. Please help
hi, The code below demonstrates one possible way of doing what you have requested... Label l1 = new Label(); l1.Text = "Hi there"; l1.Width = richTextBox1.Width; l1.Location = new Point(0,0); l1.BackColor = Color.AliceBlue; Label l2 = new Label(); l2.Width = richTextBox1.Width; l2.Location = new Point(0,l1.Bottom); l2.Text = "Howz life"; l2.BackColor = Color.Beige ; richTextBox1.Controls.Add(l1); richTextBox1.Controls.Add(l2); hope this helps you or atleast gives you an idea... this has what occured to me... regards, Aryadip. Cheers !! and have a Funky day !!
-
hi, The code below demonstrates one possible way of doing what you have requested... Label l1 = new Label(); l1.Text = "Hi there"; l1.Width = richTextBox1.Width; l1.Location = new Point(0,0); l1.BackColor = Color.AliceBlue; Label l2 = new Label(); l2.Width = richTextBox1.Width; l2.Location = new Point(0,l1.Bottom); l2.Text = "Howz life"; l2.BackColor = Color.Beige ; richTextBox1.Controls.Add(l1); richTextBox1.Controls.Add(l2); hope this helps you or atleast gives you an idea... this has what occured to me... regards, Aryadip. Cheers !! and have a Funky day !!
Hi, Thanks for that very good idea. What I want is also that this textbox should have editing capabilities also like a notepad. By doing the way you mentioned in the sample code, we might be able to edit/select only one line at a time. Thanks & Regards Mahesh
-
Hi, Thanks for that very good idea. What I want is also that this textbox should have editing capabilities also like a notepad. By doing the way you mentioned in the sample code, we might be able to edit/select only one line at a time. Thanks & Regards Mahesh
The best way to accomplish that, would be a RichtextBox. LokiSD wrote an article[^] on how to do Richtextbox background highlighting in Vb.Net. It would be worth looking into. What you would need to do, is find out the length of the line, and where the line starts. Set the selectionstart to the linestart, and selectionlength to the linelength. Then, call the function to highlight the selection color. Hope this gives you some idea's. Aaron Eldreth TheCollective4.com My Articles While much is too strange to be believed, Nothing is too strange to have happened. - T. Hardy
-
The best way to accomplish that, would be a RichtextBox. LokiSD wrote an article[^] on how to do Richtextbox background highlighting in Vb.Net. It would be worth looking into. What you would need to do, is find out the length of the line, and where the line starts. Set the selectionstart to the linestart, and selectionlength to the linelength. Then, call the function to highlight the selection color. Hope this gives you some idea's. Aaron Eldreth TheCollective4.com My Articles While much is too strange to be believed, Nothing is too strange to have happened. - T. Hardy