2012-11-29 121 views
1

当我在visual c#中添加单选按钮时,单选按钮的文本名称完全对齐到右侧。如果我动态创建一个单选按钮,并给它几个属性等。当我调试和查看它时,单选按钮的文本或名称是偏移向上,并在单选按钮的右侧?我看了几个属性,包括填充等..但我无法弄清楚如何动态纠正这一点。发生了什么事情,我该如何解决这个问题?动态单选按钮文本对齐

这里是性质的例子中,我使用的是现在

radio_ip_addresses[i] = new RadioButton(); 
radio_ip_addresses[i].Name = "radio_" + i; 
radio_ip_addresses[i].Text = ip_addresses.Dequeue(); 
radio_ip_addresses[i].Location = new Point(x, y); 
radio_ip_addresses[i].Font = new Font("Microsoft Sans Serif", 8, FontStyle.Bold); 
radio_ip_addresses[i].ForeColor = Color.White; 
radio_ip_addresses[i].TextAlign = ContentAlignment.MiddleLeft; 
radio_ip_addresses[i].Visible = true; 
radio_ip_addresses[i].Parent = this; 

image of winform

+0

我编辑了你的标题。请参阅:“[应该在其标题中包含”标签“](http://meta.stackexchange.com/questions/19190/)”,其中的共识是“不,他们不应该”。 –

+0

我无法重现您的问题。 –

+0

这是winforms吗?哪个版本? –

回答

2

感谢Rotem公司,我把你的建议,检查我早该想到的designer.cs。它是关键的自动大小:),请参阅我在designer.cs中找到的以下内容。

 this.radioButton1.AutoSize = true; 
     this.radioButton1.Location = new System.Drawing.Point(192, 50); 
     this.radioButton1.Name = "radioButton1"; 
     this.radioButton1.Size = new System.Drawing.Size(85, 17); 
     this.radioButton1.TabIndex = 71; 
     this.radioButton1.TabStop = true; 
     this.radioButton1.Text = "radioButton1"; 
     this.radioButton1.UseVisualStyleBackColor = true;