Label grow from right to left

前端 未结 6 597
逝去的感伤
逝去的感伤 2021-02-03 17:00

I have a label on my form which is on the right of the form. This label loads a dynamic text.

Sometimes the text that it loads is too long and the text crosses the borde

6条回答
  •  佛祖请我去吃肉
    2021-02-03 17:31

    you can Write it:

        public enum Leftorright { left,right}
        private Leftorright _LeftToRight = Leftorright.left;
        public Leftorright LeftToRight
        {
            get { return _LeftToRight; }
            set { _LeftToRight = value; }
        }
    
    
        protected override void OnTextChanged(EventArgs e)
        {
            int oldWidth;
            oldWidth = this.Width;
            base.OnTextChanged(e);
            if (LeftToRight == Leftorright.right && this.Width != oldWidth)
            {
                this.Left = this.Left - this.Width + oldWidth;
            }
        }
    

提交回复
热议问题