<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      帶有行數(shù)和標(biāo)尺的RichTextBox

      項(xiàng)目需要一個帶有行數(shù)和標(biāo)尺功能的RichTextBox,先是打算在RichTextBox里面自畫,但最終沒有實(shí)現(xiàn),最終用UserControl實(shí)現(xiàn)了該功能.
      1.原理:
      1)行數(shù):在RichTextBox旁邊放一個Label,設(shè)置Label字體大小,然后在RichTextBox的TextChaged方法中判斷是否換行,換行就重新為Label設(shè)值.
      2)標(biāo)尺:在RichTextBox上面放一個Panel,在Panel上面畫尺.
      代碼如下:
       1using System;
       2using System.Collections.Generic;
       3using System.ComponentModel;
       4using System.Drawing;
       5using System.Data;
       6using System.Text;
       7using System.Windows.Forms;
       8
       9namespace NumberedTextBox
      10{
      11    public partial class NumberedTextBoxUC : UserControl
      12    {
      13
      14        public NumberedTextBoxUC()
      15        {
      16            InitializeComponent();
      17
      18            numberLabel.Font = new Font(richTextBox1.Font.FontFamily, richTextBox1.Font.Size + 1.019f);
      19           
      20        }

      21
      22        int _currentLine = 0;
      23        public int CurrentLine
      24        {
      25            get
      26            {
      27                return _currentLine;
      28            }

      29            set
      30            {
      31                _currentLine = value;
      32            }

      33        }

      34        private void updateNumberLabel()
      35        {
      36            //we get index of first visible char and number of first visible line
      37            Point pos = new Point(00);
      38            int firstIndex = richTextBox1.GetCharIndexFromPosition(pos);
      39            int firstLine = richTextBox1.GetLineFromCharIndex(firstIndex);
      40
      41            //now we get index of last visible char and number of last visible line
      42            pos.X = ClientRectangle.Width;
      43            pos.Y = ClientRectangle.Height;
      44            int lastIndex = richTextBox1.GetCharIndexFromPosition(pos);
      45            int lastLine = richTextBox1.GetLineFromCharIndex(lastIndex);
      46            int myStart = this.richTextBox1.SelectionStart;
      47            int myLine = this.richTextBox1.GetLineFromCharIndex(myStart) + 1;
      48            pos = richTextBox1.GetPositionFromCharIndex(lastIndex);
      49            if (lastIndex > _currentLine||lastIndex<_currentLine)
      50            {
      51                //finally, renumber label
      52                numberLabel.Text = "";
      53                for (int i = firstLine; i <= lastLine + 1; i++)
      54                {
      55                    numberLabel.Text += i + 1 + "\n";
      56                }

      57            }

      58            _currentLine = lastIndex;
      59            //this is point position of last visible char, we'll use its Y value for calculating numberLabel size 
      60
      61        }

      62
      63
      64        private void richTextBox1_TextChanged(object sender, EventArgs e)
      65        {
      66            updateNumberLabel();            
      67        }

      68
      69        private void richTextBox1_VScroll(object sender, EventArgs e)
      70        {
      71            //move location of numberLabel for amount of pixels caused by scrollbar
      72            int d = richTextBox1.GetPositionFromCharIndex(0).Y % (richTextBox1.Font.Height + 1);
      73            numberLabel.Location = new Point(0, d);
      74
      75            updateNumberLabel();
      76        }

      77
      78        private void richTextBox1_Resize(object sender, EventArgs e)
      79        {
      80            richTextBox1_VScroll(nullnull);
      81        }

      82
      83        private void richTextBox1_FontChanged(object sender, EventArgs e)
      84        {
      85            updateNumberLabel();
      86            richTextBox1_VScroll(nullnull);
      87        }
                  
      88
      89
      90    }

      91}

      92
       1using System;
       2using System.Collections.Generic;
       3using System.Text;
       4using System.Drawing;
       5using System.Windows.Forms;
       6
       7namespace Yqun.Client.ReportTools
       8{
       9    public class RulerPanel:Panel
      10    {
      11        protected override void OnPaint(PaintEventArgs e)
      12        {
      13            Graphics g = e.Graphics;
      14            int top = 0;
      15            int width = e.ClipRectangle.Width;
      16            int temHeight = 5;
      17            for (int i = 0; i < width-5; )
      18            {
      19                
      20                int height = temHeight;
      21                int j = i / 5;
      22                if (j % 10 == 0)
      23                {
      24                    height = 15;
      25                }

      26                else if (j % 5 == 0)
      27                {
      28                    height = 10;
      29                }
                     
      30                Pen p = new Pen(new SolidBrush(Color.Black));
      31                p.Width = 1;
      32                g.DrawLine(p, i + 5, top, i + 5, top + height);
      33                i += 5;               
      34            }

      35            g.Flush();
      36            base.OnPaint(e);
      37        }

      38    }

      39}

      40

      最終實(shí)現(xiàn)效果圖:
      posted @ 2006-09-01 09:01  Robin Zhang  閱讀(6450)  評論(17)    收藏  舉報(bào)
      主站蜘蛛池模板: 中文字幕国产精品综合| 国产性生大片免费观看性| 中文字幕国产精品综合| 麻豆a级片| 尹人香蕉久久99天天拍| 亚洲男人av天堂久久资源| 男人av无码天堂| 久久中文字幕日韩无码视频| 自拍偷自拍亚洲一区二区| 成人午夜免费无码视频在线观看| 99RE8这里有精品热视频| 综合区一区二区三区狠狠| 性视频一区| jlzz大jlzz大全免费| 亚洲一级特黄大片在线观看| 曰韩无码二三区中文字幕| 自拍视频在线观看成人| 亚洲成av人片在www鸭子| 少妇人妻无码专区在线视频| 亚洲精品中文综合第一页| 亚洲一区二区三区啪啪| 欧美成人h精品网站| 久久久无码精品亚洲日韩蜜桃| 国产精品午夜福利合集| 宁津县| 日韩中文字幕亚洲精品| 亚洲中文字幕无码中字| 萨迦县| 国产成人自拍小视频在线| 日本中文一区二区三区亚洲| 精品亚洲国产成人| 亚洲第一区二区国产精品| 国产精品免费看久久久| 黑人巨大粗物挺进了少妇| 高清无码爆乳潮喷在线观看| 延安市| 国产精品人成视频免费播放| 午夜精品福利亚洲国产| 国产免费高清69式视频在线观看 | 亚洲 一区二区 在线| 99精品日本二区留学生|