在c#中镜像用户控件
本文关键字:用户 控件 镜像 | 更新日期: 2023-09-27 18:13:26
我有一些不支持RightToLeft
布局的用户控件,我只有dll。我想实现RightToLeft
布局在这些控件的代码。
我该怎么做呢?
注意:我尝试使用TableLayoutPanel
和FlowLayoutPanel
,但问题仍然存在
您必须使用一些逻辑手动执行。
private bool isLeft = true;
private void SwapPosition()
{
isLeft = !isLeft;
foreach (Control cnt in this.Controls)
SwapPosition(cnt);
}
private void SwapPosition(Control cnt)
{
cnt.Left = cnt.Parent.Width - (cnt.Left + cnt.Width);
///Assign other properties also
///ie. cnt.RightToLeft = !isLeft
///if (isLeft) then NormalFont else Hebrew or any
foreach (Controls cntChild in cnt.Controls)
RightToLeft(cntChild);
}