如何在System.Windows.Controls.TextBox C#中设置位置或类似属性

库勒布

我正在做一个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] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何在System.Windows.Forms.Form中添加System.Windows.Controls.WebBrowser

来自分类Dev

如何从Windows.UI.Xaml.Controls.TextBox中的不同线程中读取文本-Windows Phone 8.1

来自分类Dev

如何在System.Windows.Controls.ListView中设置当前关注的项目?

来自分类Dev

如何在System.Windows.Forms.TextBox powershell中获得焦点?

来自分类Dev

替代this.Controls [textbox] .Text = txt; 对于Windows Phone 7

来自分类Dev

C# WPF System.Windows.Controls.TreeView 如何更改选定节点

来自分类Dev

更改类system.windows.controls.menuitem中的标题/内容?

来自分类Dev

如何在不显示System.Windows.Controls.WebBrowser的情况下使用它?

来自分类Dev

如何使用C#在按钮单击事件上的textBox中设置光标位置?

来自分类Dev

解决Set属性'System.Windows.Controls.Decorator.Child'在DataTemplate中引发异常

来自分类Dev

如何在Windows应用商店中阻止将文本粘贴到TextBox中?

来自分类Dev

如何在Windows应用商店中阻止将文本粘贴到TextBox中?

来自分类Dev

如何从System.Windows.Forms.TextBox捕获值?

来自分类Dev

TextBox-TextChanged事件Windows C#

来自分类Dev

Powershell System.Windows.Forms.TextBox

来自分类Dev

在“ System.Windows.Controls.Button”的名称范围中找不到名称

来自分类Dev

如何在Windows 10的窗口中获取TextBox控件的句柄

来自分类Dev

如何在C#的TextBox中显示char数组?

来自分类Dev

在C#中隐藏TextBox的内容(Windows Store App)

来自分类Dev

在C#中隐藏TextBox的内容(Windows Store App)

来自分类Dev

如何在Windows 10 UWP应用中删除TextBox控件的默认“粘贴”上下文菜单项?

来自分类Dev

无法获取标签和标题以显示在保存的图表中(C#.NET,System.Windows.Controls.DataVisualization.Charting)

来自分类Dev

无法获取标签和标题以显示在保存的图表中(C#.NET,System.Windows.Controls.DataVisualization.Charting)

来自分类Dev

如何在WinForm中增长TextBox?

来自分类Dev

如何在MVC中更改textBox的大小?

来自分类Dev

'System.Windows.Controls.Image'不包含'FromFile'的定义

来自分类Dev

使用继承XAML内部的System.Windows.Controls.Control的类

来自分类Dev

将System.Windows.Controls.Image加载到WritableBitmap对象

来自分类Dev

错误:System.Windows.Controls.UIElementCollection'不包含'OfType'的定义

Related 相关文章

  1. 1

    如何在System.Windows.Forms.Form中添加System.Windows.Controls.WebBrowser

  2. 2

    如何从Windows.UI.Xaml.Controls.TextBox中的不同线程中读取文本-Windows Phone 8.1

  3. 3

    如何在System.Windows.Controls.ListView中设置当前关注的项目?

  4. 4

    如何在System.Windows.Forms.TextBox powershell中获得焦点?

  5. 5

    替代this.Controls [textbox] .Text = txt; 对于Windows Phone 7

  6. 6

    C# WPF System.Windows.Controls.TreeView 如何更改选定节点

  7. 7

    更改类system.windows.controls.menuitem中的标题/内容?

  8. 8

    如何在不显示System.Windows.Controls.WebBrowser的情况下使用它?

  9. 9

    如何使用C#在按钮单击事件上的textBox中设置光标位置?

  10. 10

    解决Set属性'System.Windows.Controls.Decorator.Child'在DataTemplate中引发异常

  11. 11

    如何在Windows应用商店中阻止将文本粘贴到TextBox中?

  12. 12

    如何在Windows应用商店中阻止将文本粘贴到TextBox中?

  13. 13

    如何从System.Windows.Forms.TextBox捕获值?

  14. 14

    TextBox-TextChanged事件Windows C#

  15. 15

    Powershell System.Windows.Forms.TextBox

  16. 16

    在“ System.Windows.Controls.Button”的名称范围中找不到名称

  17. 17

    如何在Windows 10的窗口中获取TextBox控件的句柄

  18. 18

    如何在C#的TextBox中显示char数组?

  19. 19

    在C#中隐藏TextBox的内容(Windows Store App)

  20. 20

    在C#中隐藏TextBox的内容(Windows Store App)

  21. 21

    如何在Windows 10 UWP应用中删除TextBox控件的默认“粘贴”上下文菜单项?

  22. 22

    无法获取标签和标题以显示在保存的图表中(C#.NET,System.Windows.Controls.DataVisualization.Charting)

  23. 23

    无法获取标签和标题以显示在保存的图表中(C#.NET,System.Windows.Controls.DataVisualization.Charting)

  24. 24

    如何在WinForm中增长TextBox?

  25. 25

    如何在MVC中更改textBox的大小?

  26. 26

    'System.Windows.Controls.Image'不包含'FromFile'的定义

  27. 27

    使用继承XAML内部的System.Windows.Controls.Control的类

  28. 28

    将System.Windows.Controls.Image加载到WritableBitmap对象

  29. 29

    错误:System.Windows.Controls.UIElementCollection'不包含'OfType'的定义

热门标签

归档