<bdo id='gzHmX'></bdo><ul id='gzHmX'></ul>

  1. <small id='gzHmX'></small><noframes id='gzHmX'>

  2. <tfoot id='gzHmX'></tfoot>

      <legend id='gzHmX'><style id='gzHmX'><dir id='gzHmX'><q id='gzHmX'></q></dir></style></legend>
    1. <i id='gzHmX'><tr id='gzHmX'><dt id='gzHmX'><q id='gzHmX'><span id='gzHmX'><b id='gzHmX'><form id='gzHmX'><ins id='gzHmX'></ins><ul id='gzHmX'></ul><sub id='gzHmX'></sub></form><legend id='gzHmX'></legend><bdo id='gzHmX'><pre id='gzHmX'><center id='gzHmX'></center></pre></bdo></b><th id='gzHmX'></th></span></q></dt></tr></i><div id='gzHmX'><tfoot id='gzHmX'></tfoot><dl id='gzHmX'><fieldset id='gzHmX'></fieldset></dl></div>

      如何在 C#/Windows 窗体中翻转/旋转标签?

      How can I flip/rotate the label in C#/Windows Forms?(如何在 C#/Windows 窗体中翻转/旋转标签?)
          <bdo id='ZTOdm'></bdo><ul id='ZTOdm'></ul>

            • <legend id='ZTOdm'><style id='ZTOdm'><dir id='ZTOdm'><q id='ZTOdm'></q></dir></style></legend>
                  <tbody id='ZTOdm'></tbody>
              1. <i id='ZTOdm'><tr id='ZTOdm'><dt id='ZTOdm'><q id='ZTOdm'><span id='ZTOdm'><b id='ZTOdm'><form id='ZTOdm'><ins id='ZTOdm'></ins><ul id='ZTOdm'></ul><sub id='ZTOdm'></sub></form><legend id='ZTOdm'></legend><bdo id='ZTOdm'><pre id='ZTOdm'><center id='ZTOdm'></center></pre></bdo></b><th id='ZTOdm'></th></span></q></dt></tr></i><div id='ZTOdm'><tfoot id='ZTOdm'></tfoot><dl id='ZTOdm'><fieldset id='ZTOdm'></fieldset></dl></div>
                <tfoot id='ZTOdm'></tfoot>

                <small id='ZTOdm'></small><noframes id='ZTOdm'>

                本文介绍了如何在 C#/Windows 窗体中翻转/旋转标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                如何在 C# Windows 窗体中翻转/旋转标签?

                How can I flip/rotate the label in C# Windows Forms?

                我将背景图片设置为我的标签.

                I set the background image to my label.

                在每个时间间隔,它都会向右移动三个像素.当它到达表单结束位置时,我需要将标签翻转并返回.

                At every time interval it moves three pixels to the right side. When it reaches the form end position I need the label to be flipped and turned back.

                我尝试了以下方法,但没有得到解决方案.

                I have tried the following way, but I didn't get the solution.

                private void timer1_Tick(object sender, EventArgs e){
                
                    if (label2.Location.X < this.Width)
                        label2.Location = new Point(label2.Location.X + incr, label2.Location.Y);
                    else
                    {
                        incr = -2;
                        label2.Location = new Point(label2.Location.X - 50, label2.Location.Y);
                        label1.Image.RotateFlip();
                    }
                    this.Refresh();
                }
                

                推荐答案

                创建一个类,newlabel,它可以按用户指定的任意角度旋转它的Text.

                Create a class, newlabel, which can rotate its Text on any angle specified by the user.

                extend label class& override paint method
                

                您可以通过代码使用它,也可以简单地从工具箱中拖动它.

                You can use it by code or simply dragging from the ToolBox.

                using System.Drawing;
                
                class newLabel : System.Windows.Forms.Label
                {
                    public int RotateAngle { get; set; }  
                    public string NewText { get; set; }   
                    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
                    {
                        Brush b =new SolidBrush(this.ForeColor);           
                        e.Graphics.TranslateTransform(this.Width / 2, this.Height / 2);
                        e.Graphics.RotateTransform(this.RotateAngle);
                        e.Graphics.DrawString(this.NewText, this.Font,b , 0f, 0f);
                        base.OnPaint(e);
                    }
                }
                

                现在将要使用的自定义控件拖到表单中.

                Now drag this custom control to be used into your form.

                您必须设置以下属性.

                newlbl.Text = "";           
                newlbl.AutoSize = false;      
                newlbl.NewText = "ravindra";     
                newlbl.ForeColor = Color.Green;  
                newlbl.RotateAngle = -90; 
                

                只需更改 RotateAngle 属性即可根据需要更改角度.

                Change angle as required by simply changing the RotateAngle property.

                这篇关于如何在 C#/Windows 窗体中翻转/旋转标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                Cannot remove items from ListBox(无法从列表框中删除项目)
                Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)

                  <small id='czZh2'></small><noframes id='czZh2'>

                • <i id='czZh2'><tr id='czZh2'><dt id='czZh2'><q id='czZh2'><span id='czZh2'><b id='czZh2'><form id='czZh2'><ins id='czZh2'></ins><ul id='czZh2'></ul><sub id='czZh2'></sub></form><legend id='czZh2'></legend><bdo id='czZh2'><pre id='czZh2'><center id='czZh2'></center></pre></bdo></b><th id='czZh2'></th></span></q></dt></tr></i><div id='czZh2'><tfoot id='czZh2'></tfoot><dl id='czZh2'><fieldset id='czZh2'></fieldset></dl></div>
                • <tfoot id='czZh2'></tfoot><legend id='czZh2'><style id='czZh2'><dir id='czZh2'><q id='czZh2'></q></dir></style></legend>
                      <tbody id='czZh2'></tbody>

                    • <bdo id='czZh2'></bdo><ul id='czZh2'></ul>