Using the WS_EX_LAYOUTRTL
flag is causing black bars to be visible on the edges of controls. The black bars are on the left edge of each button. How can the black bars be prevented while still using the WS_EX_LAYOUTRTL
flag?
public class MyForm : Form {
Button btn1 = new Button { Text = "Button1" };
ComboBox combo1 = new ComboBox();
Button btn2 = new Button { Text = "Button2" };
public MyForm() : base() {
Size = new Size(600, 100);
StartPosition = FormStartPosition.CenterScreen;
var mc = new MyControl();
int x = 0;
btn1.Location = new Point(x, 0);
x += btn1.Size.Width + 10;
combo1.Location = new Point(x, 0);
x += combo1.Size.Width + 10;
btn2.Location = new Point(x, 0);
mc.Controls.AddRange(new Control[] { btn1, combo1, btn2 });
Controls.Add(mc);
}
private class MyControl : UserControl {
private const int WS_EX_LAYOUTRTL = 0x00400000;
public MyControl() : base() {
this.Dock = DockStyle.Top;
this.AutoSize = true;
this.BackColor = Color.LightPink;
}
protected override CreateParams CreateParams {
get {
var cp = base.CreateParams;
cp.ExStyle |= WS_EX_LAYOUTRTL;
return cp;
}
}
}
}