当前位置: 首页>>代码示例>>C#>>正文


C# RichTextBox.Show方法代码示例

本文整理汇总了C#中System.Windows.Forms.RichTextBox.Show方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.Show方法的具体用法?C# RichTextBox.Show怎么用?C# RichTextBox.Show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.RichTextBox的用法示例。


在下文中一共展示了RichTextBox.Show方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: rich_TextChanged

		private void rich_TextChanged(object sender, EventArgs e)
		{
			if (m_busy)
				return;

			m_busy = true;

			m_buffer.Text = m_active.Text;

			m_buffer.SelectAll();
			m_buffer.SelectionColor = m_defaultColor;

			ControlEventArgs args = new ControlEventArgs(m_buffer);
			OnHighlight(args);

			m_buffer.SelectionStart = m_active.SelectionStart;
			m_buffer.SelectionLength = m_active.SelectionLength;

			Native.SCROLLINFO si = new Native.SCROLLINFO();
			si.Size = (uint)Marshal.SizeOf(typeof(Native.SCROLLINFO));
			si.Mask = Native.SIF_POS;
			Native.GetScrollInfo(m_active.Handle, (int)Native.SB_VERT, ref si);
			Native.SetScrollInfo(m_buffer.Handle, (int)Native.SB_VERT, ref si, true);

			uint wparam = ((uint)si.Pos << 16) + Native.SB_THUMBPOSITION;
			Native.SendMessage(m_buffer.Handle, Native.WM_VSCROLL, wparam, 0);
			Native.SendMessage(m_buffer.Handle, Native.WM_VSCROLL, Native.SB_ENDSCROLL, 0);

			m_busy = false;

			RichTextBox temp = m_active;
			m_active = m_buffer;
			m_buffer = temp;

			m_active.BringToFront();
			m_active.Show();
			m_buffer.Hide();
			m_active.Focus();
		}
开发者ID:jozefizso,项目名称:StyleCopPlus,代码行数:39,代码来源:HighlightTextBox.cs

示例2: Message1

        public Message1(string content, Font temp)
        {
            InitializeComponent();
            //lbl_content.Font = temp;
            ////lbl_user.Text = user;
            //lbl_content.Text = content;
            //Size size = TextRenderer.MeasureText(lbl_content.Text, lbl_content.Font);
            //if (size.Width > 300)
            //{
            //    int count = size.Width / 300;
            //    int lenght = content.Length / (count + 1);
            //    int tile = size.Width / content.Length;
            //    int sizeText = 300 / tile;
            //    for (int i = 0; i < count; i++)
            //    {
            //        content = content.Insert((i + 1) * sizeText , "\n");
            //    }
            //    this.Width = 300 + 30;
            //    lbl_content.Text = content;
            //    Size size1 = TextRenderer.MeasureText(lbl_content.Text, lbl_content.Font);
            //    this.Height = size1.Height/(count+1)*count + 15+Math.Abs(size.Height/2-size1.Height/(count+1));
            //}
            //else
            //{
            //    if (size.Width+30 > this.Width)
            //    {
            //        this.Width = size.Width+30;
            //    }
            //    lbl_content.Text = content;
            //}

            ////////////////
            RichTextBox rtb = new RichTextBox();
            Size size = TextRenderer.MeasureText(content, temp);

            if (size.Width > 300)
            {
                int count = size.Width / 300;
                int lenght = content.Length / (count + 1);
                int tile = size.Width / content.Length;
                int sizeText = 300 / tile;
                for (int i = 0; i < count; i++)
                {
                    content = content.Insert((i + 1) * sizeText + i * 2, "\n");
                }
                this.Width = 300 + 50;
                //rtb.Text = content;
                Size size1 = TextRenderer.MeasureText(content, temp);
                this.Height = size1.Height + 25 + (size.Height / 2 - size1.Height / (count + 1));
            }
            else
            {
                if (size.Width + 30 > this.Width)
                {
                    this.Width = size.Width + 50;

                }
                else
                {
                    this.Height += 10;
                }
                //rtb.Text = content;
            }

            rtb.BorderStyle = BorderStyle.None;
            rtb.Multiline = true;
            int _width = this.Size.Width;
            this.Size = new System.Drawing.Size(this.Width,this.Height);
            rtb.Height = this.Height;
            rtb.Width = this.Width;
            rtb.Font = temp;

            string chuoi_tam;
            for (int i = 0; i < content.Length; i++)
            {
                chuoi_tam = "";
                if (content[i] == ':' && i + 2 < content.Length)
                {
                    chuoi_tam += content[i + 1];
                    chuoi_tam += content[i + 2];
                    if (image_name(chuoi_tam))
                    {
                        rtb.Height += 50;
                        this.Height += 10;
                        Bitmap myBitmap = new Bitmap(_image_icon);
                        //// Copy bitmap vào clipboard.
                        Clipboard.SetDataObject(myBitmap);
                        // Lấy định dạng của đối tượng ảnh
                        DataFormats.Format myFormat = DataFormats.GetFormat(DataFormats.Bitmap);
                        // Kiểm tra xem có thể copy định dạng ảnh vào RichTextBox
                        if (rtb.CanPaste(myFormat))
                        {
                            //nếu được thì "add" vào
                            rtb.Paste(myFormat);
                            rtb.Show();
                        }
                        i += 2;
                    }
                    else
                    {
//.........这里部分代码省略.........
开发者ID:dhcntt,项目名称:DoAnC-UIT,代码行数:101,代码来源:Message1.cs


注:本文中的System.Windows.Forms.RichTextBox.Show方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。