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

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

      <tfoot id='aWmpA'></tfoot>

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

        如何使 RightToLeftLayout 适用于 GroupBoxes 和 Panels 中

        时间:2023-08-25

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

          <tfoot id='YrcAH'></tfoot>
              <bdo id='YrcAH'></bdo><ul id='YrcAH'></ul>
                1. <legend id='YrcAH'><style id='YrcAH'><dir id='YrcAH'><q id='YrcAH'></q></dir></style></legend>

                    <tbody id='YrcAH'></tbody>
                  <i id='YrcAH'><tr id='YrcAH'><dt id='YrcAH'><q id='YrcAH'><span id='YrcAH'><b id='YrcAH'><form id='YrcAH'><ins id='YrcAH'></ins><ul id='YrcAH'></ul><sub id='YrcAH'></sub></form><legend id='YrcAH'></legend><bdo id='YrcAH'><pre id='YrcAH'><center id='YrcAH'></center></pre></bdo></b><th id='YrcAH'></th></span></q></dt></tr></i><div id='YrcAH'><tfoot id='YrcAH'></tfoot><dl id='YrcAH'><fieldset id='YrcAH'></fieldset></dl></div>
                2. 本文介绍了如何使 RightToLeftLayout 适用于 GroupBoxes 和 Panels 中的控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  According to MSDN

                  form.RightToLeftLayout = True;
                  form.RightToLeft = ifWeWantRTL() ? RightToLeft.True : RightToLeft.False;
                  

                  is enough to mirrow the form content for RTL languages.

                  But controls placement gets mirrowed only for controls immediately on the form,
                  those inside a GroupBox or a Panel are not mirrowed, unless I put them on a TableLayoutPanel or a FlowLayoutPanel fisrt.

                  This is a lot of manual work to place a TableLayoutPanel inside each GroupBox, and especially to rearrange the controls (one control per table cell, padding, margin, etc)

                  Is there an easier way to make mirrowing work for all controls?

                  Or at least, how can I bypass the rearranging step, for it is quite a task with our number of forms?


                  Edit: RightToLeft property for each control on the form by default is inherited,
                  so Panels and GroupBoxes always have the needed RightToLeft setting.
                  Nevertheless, I tryed to reassign it for them both programmatically and from designer, it did not help.

                  解决方案

                  It does seen that you have quite a nasty problem on your hands. Have played with it for a while and come up with the following:

                  Making use of a little recursion you can run though all the controls and do the manaul RTL conversion for those controls trapped in Pannels and GroupBoxes.

                  This is a quick little mock of code that I slapped together. I would suggest you put this in your BaseForm (heres hoping you have one of these) and call on base form load.

                  private void SetRTL (bool setRTL)
                  {
                      ApplyRTL(setRTL, this);
                  }
                  
                  private void ApplyRTL(bool yes, Control startControl)
                  {
                      if ((startControl is Panel ) || (startControl is GroupBox))
                      {
                          foreach (Control control in startControl.Controls)
                          {
                              control.Location = CalculateRTL(control.Location, startControl.Size, control.Size);
                          }
                      }
                  
                      foreach (Control control in startControl.Controls)
                          ApplyRTL(yes, control);
                  }
                  
                  private Point CalculateRTL (Point currentPoint, Size parentSize, Size currentSize)
                  {
                      return new Point(parentSize.Width - currentSize.Width - currentPoint.X, currentPoint.Y);
                  }
                  

                  这篇关于如何使 RightToLeftLayout 适用于 GroupBoxes 和 Panels 中的控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:十进制字符串与千位分隔符? 下一篇:英文桌面 C#.net 应用程序中的阿拉伯语本地化

                  相关文章

                  最新文章

                  <legend id='TbO1v'><style id='TbO1v'><dir id='TbO1v'><q id='TbO1v'></q></dir></style></legend>

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

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

                    1. <tfoot id='TbO1v'></tfoot>