Click here to Skip to main content
15,748,049 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to create a textbox or richtextbox and it every row has a rowline?
like word's gridlines,in every can show it or hide all lines.
rowline!can you help me?
Sergey Alexandrovich Kryukov 28-Mar-13 11:46am    
Row in what? Nothing is clear...
Richard MacCutchan 28-Mar-13 11:46am    
I don't think text boxes (rich or poor) are designed to do that; you probably need to use a datagrid of some type.
ali_heidari_ 28-Mar-13 11:58am    
maybe its better make own usercontrol !
Richard MacCutchan 28-Mar-13 12:09pm    
And you are telling me this why?
ali_heidari_ 28-Mar-13 12:28pm    
a control inherited from textbox , can do some addition work!?

1 solution

like this,but I dont get rowhight.

class rowlineTextbox : TextBox
          const int WM_PAINT = 0xF;
        protected override void WndProc(ref Message m)
            base.WndProc(ref m);
            if (m.Msg == WM_PAINT||m.Msg == 0x133) 
         private void aaa()
            using (Graphics g = Graphics.FromHwnd(base.Handle))
                Pen tPen;
                Size CSize = this.ClientSize;
                int cordX1 = this.Location.X + this.Padding.Left;
                int cordX2 = CSize.Width - this.Padding.Right;
                int cordY1 = this.Location.Y + this.Padding.Top;
                int cordY2 = cordY1;

                tPen = new Pen(Color.Black, 1.0F);
                g.DrawLine(tPen, cordX1, cordY1, cordX2, cordY2);

                for (int i = cordY1; i <= CSize.Height; i += this.Font.Height)
                    g.DrawLine(tPen, cordX1, i, cordX2, i);

Share this answer
Richard MacCutchan 29-Mar-13 6:37am    
What results do you get? Use your debugger to step through the code and check the values of all the variables at each step.

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