我正在做一个System.Windows.Controls.TextBox
。我需要将它设置为System.Windows.Controls.TextBox
,而不是System.Windows.Forms.TextBox
,因为方法需要将其用于SpellCheck。我已经找到或查看了此控件的大多数其他属性,但是无论在Google,Stack Overflow还是Microsoft上都找不到。
这是我正在使用的代码:
this.tbSearch.Name = "tbSearch";
//this.tbSearch.LOCATION //this needs to be replaced
this.tbSearch.Width = 313;
this.tbSearch.Height = 20;
this.tbSearch.TabIndex = 2;
this.tbSearch.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.tbSearch_TextChanged);
任何帮助表示赞赏!
编辑:
我正在使用WinForms。
试试该Margin
属性,一个System.Windows.Thickness
对象:
this.tbSearch.Margin = new Thickness(0, 0, 50, 50);
更新
似乎完全可以在WPF中工作。
CS:
private void Button_Click(object sender, RoutedEventArgs e)
{
this.tbSearch.Margin = new Thickness(this.tbSearch.Margin.Left - 10,
this.tbSearch.Margin.Top - 10,
this.tbSearch.Margin.Right,
this.tbSearch.Margin.Bottom);
}
XAML:
<Button Content="Button" HorizontalAlignment="Left" Margin="55,37,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
<TextBox Name="tbSearch" HorizontalAlignment="Left" Height="23" Margin="198,159,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
WinForms与ElementHost
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句