2012-11-29 122 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;