textbox 相关问题

文本框是一个图形用户界面元素,它允许简单的输入文本,通常只有一行文本。

如何编写文本框中鼠标滚动时发生的事件?

我想更改鼠标滚动时文本框的数量。我有一个滚动文本框,但我不想使用它。有与此相关的活动吗? 我应该编写一个文本框事件吗?如果是的话,如何...

回答 4 投票 0

如何从 WinForms 中的 TextBox 中移除焦点?

我需要从几个文本框中删除焦点。我尝试使用: textBox1.Focused = false; 它的 ReadOnly 属性值为 true。 然后我尝试将焦点设置在表单上,以便将其删除......

回答 21 投票 0

WPF圆角文本框

我不懂WPF,现在正在学习。我正在寻找 WPF 中的圆角 TextBox。所以我搜索了Google并找到了一段XAML: 我不了解WPF,现在正在学习。我在 WPF 中寻找圆角TextBox。所以我在Google上搜索并找到了一块XAML: <!–Rounded Corner TextBoxes–> <ControlTemplate x:Key=”RoundTxtBoxBaseControlTemplate” TargetType=”{x:Type Control}”> <Border Background=”{TemplateBinding Background}” x:Name=”Bd” BorderBrush=”{TemplateBinding BorderBrush}” BorderThickness=”{TemplateBinding BorderThickness}” CornerRadius=”6″> <ScrollViewer x:Name=”PART_ContentHost”/> </Border> <ControlTemplate.Triggers> <Trigger Property=”IsEnabled” Value=”False”> <Setter Property=”Background” Value=”{DynamicResource {x:Static SystemColors.ControlBrushKey}}” TargetName=”Bd”/> <Setter Property=”Foreground” Value=”{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}”/> </Trigger> <Trigger Property=”Width” Value=”Auto”> <Setter Property=”MinWidth” Value=”100″/> </Trigger> <Trigger Property=”Height” Value=”Auto”> <Setter Property=”MinHeight” Value=”20″/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> 所以请告诉我将其粘贴到哪里XAML。请详细帮助我。我是 WPF 的初学者。 @Smolla 在对 @Daniel Casserly 的回答的评论中给出了更好的答案: <TextBox Text="TextBox with CornerRadius"> <TextBox.Resources> <Style TargetType="{x:Type Border}"> <Setter Property="CornerRadius" Value="3"/> </Style> </TextBox.Resources> </TextBox> 如果您希望 TextBox 和 ListBox 的所有边框都有圆角,请将样式放入您的 Window 或 App 中<Resources>。 在 WPF 中,您可以修改或重新创建控件的外观。因此,如果您的示例他们所做的是通过修改现有 ControlTemplate 的 TextBox 来更改文本框的外观。因此,要查看和探索这段代码,只需使用下面的代码 <Window x:Class="WpfApplication4.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Window.Resources> <ControlTemplate x:Key="TextBoxBaseControlTemplate" TargetType="{x:Type TextBoxBase}"> <Border Background="{TemplateBinding Background}" x:Name="Bd" BorderBrush="Black" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="10"> <ScrollViewer x:Name="PART_ContentHost"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" TargetName="Bd"/> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/> </Trigger> <Trigger Property="Width" Value="Auto"> <Setter Property="MinWidth" Value="100"/> </Trigger> <Trigger Property="Height" Value="Auto"> <Setter Property="MinHeight" Value="20"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Window.Resources> <Grid> <TextBox Template="{StaticResource TextBoxBaseControlTemplate}" Height="25" Margin="5"></TextBox> </Grid> 因此,我们在窗口的资源部分声明了一个静态资源,并在 Template 的 TextBox 属性中使用了 Resource TextBoxBaseControlTemplate 作为 Template="{StaticResource TextBoxBaseControlTemplate}" 。 自定义 WPF 控件的模板只需参考此文档即可获得想法 http://msdn.microsoft.com/en-us/magazine/cc163497.aspx 您可以使用以下样式将所有文本框更改为圆角: <Style TargetType="{x:Type TextBox}"> <Style.Resources> <Style TargetType="{x:Type Border}"> <Setter Property="CornerRadius" Value="3" /> </Style> </Style.Resources> </Style> 受到以下答案的启发:https://stackoverflow.com/a/13858357/3387453 只需将文本框的 BorderThickness 设置为零即可在文本框周围添加边框。 <Border BorderThickness="1" BorderBrush="Black" CornerRadius="10" Padding="2" HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBox Text="Hello ! " BorderThickness="0"/> </Border> 输出如图所示! 这个问题在 msdn 上得到了很好的讨论: http://social.msdn.microsoft.com/forums/en-US/wpf/thread/549775ed-1c2a-4911-9078-d9c724294fb3/ 尝试那里的解决方案,它们非常详细,并且足够详细,让您知道将代码放在哪里。 您可以使用附加属性来设置TextBox边框半径(同样适用于按钮)。 为附加属性创建类 public class CornerRadiusSetter { public static CornerRadius GetCornerRadius(DependencyObject obj) => (CornerRadius)obj.GetValue(CornerRadiusProperty); public static void SetCornerRadius(DependencyObject obj, CornerRadius value) => obj.SetValue(CornerRadiusProperty, value); public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.RegisterAttached(nameof(Border.CornerRadius), typeof(CornerRadius), typeof(CornerRadiusSetter), new UIPropertyMetadata(new CornerRadius(), CornerRadiusChangedCallback)); public static void CornerRadiusChangedCallback(object sender, DependencyPropertyChangedEventArgs e) { Control control = sender as Control; if (control == null) return; control.Loaded -= Control_Loaded; control.Loaded += Control_Loaded; } private static void Control_Loaded(object sender, EventArgs e) { Control control = sender as Control; if (control == null || control.Template == null) return; control.ApplyTemplate(); Border border = control.Template.FindName("border", control) as Border; if (border == null) return; border.CornerRadius = GetCornerRadius(control); } } 然后您可以使用附加属性语法来设置多个文本框的样式,而无需重复样式: <TextBox local:CornerRadiusSetter.CornerRadius="10" /> <TextBox local:CornerRadiusSetter.CornerRadius="5, 0, 0, 5" /> <TextBox local:CornerRadiusSetter.CornerRadius="10, 4, 18, 7" /> 以困难的方式去做。 在 Visual Studio 中创建一个新的空 WPF 项目。将 TextBox 添加到主 Window。然后将鼠标放在 TextBox 上,右键单击并选择 编辑模板、编辑副本...。在出现的对话框中,选择应用于全部和此文档。 您现在拥有 TextBox 模板的副本。现在看看名称为 Border 的 border。只需添加一个 CornerRadius 即可。 接下来将此代码复制/粘贴到您的App.xaml中的/Application/Application.Resources/ResourceDictionary中。 它比其他解决方案需要更多的时间,它更复杂,但更干净,一旦你掌握了这个过程,你就可以使用 WPF 做任何你想做的事情。 这读起来很有趣。

回答 7 投票 0

WPF TextBox为所有控件设置通用的StringFormat

是否可以为项目中的所有(或部分)文本框设置 Binding 属性的 StringFormat ?是的,我可以写一些类似的东西 是否可以为项目中的所有(或部分)文本框设置 Binding 属性的 StringFormat ?是的,我可以写类似的东西 <TextBox x:Name="SetPosition" Style="{StaticResource TextBoxSmallStyle}" Text="{Binding SetPosition, Mode=TwoWay, StringFormat='{}{0:#0.0}'}" /> 但是为许多相同的文本框设置它太无聊了)))如你所见,我使用的样式包括高度,宽度等。我无法覆盖样式中的绑定属性,因为需要将此样式与任何绑定路径属性一起使用,但绑定只能完全覆盖。 哪里有解决方法? 附:我已经使用的不是标准 TextBox,而是覆盖了我的特殊功能的控件。我可以覆盖 Binding 以使用组件的代码隐藏吗? 我对在“查看”时需要“特殊”处理的属性使用(可重用)“功能”代码;例如 public string FirstName { get; set; } public string LastName { get; set; } public string FullName => this.FirstName + " " + this.LastName; ... TextBlock Text={Binding FullName} ...

回答 1 投票 0

滚动条和...文本框的奇怪问题? (垂直内容对齐)

我有这个奇怪的问题,我不明白是什么原因造成的。在我的整个项目中,文本框无法垂直居中,无论我使用什么,padding,VerticalContentAlign...

回答 1 投票 0

将旋转框绑定到文本框

我们如何获取 Spinbox 的值(从 1 到 10)然后将其乘以一个数字(例如:100)?然后将结果显示到TKINTER中的文本框中??? 我尝试了.get()方法来获取值,t...

回答 1 投票 0

将pinbox绑定到textbox

我们如何获取 Spinbox 的值(从 1 到 10)然后将其乘以一个数字(例如:100)?然后将结果显示到TKINTER中的文本框中??? 我尝试了.get()方法来获取值,t...

回答 1 投票 0

Tkinter Python - 将旋转框绑定到文本框

我们如何获取 Spinbox 的值(从 1 到 10),然后将其乘以一个数字(例如:100)。然后将结果显示到TKINTER中的文本框中??? 我尝试了 .get() 方法来获取值,...

回答 1 投票 0

Excel activex 文本框 - 无法选择输入

Office 365/Excel,我执行了以下操作: 打开新的空白工作簿.工作表 插入 activex 文本框 3) 属性 - 链接到单元格 (G1)。 但是,当退出设计模式并选择要键入的文本框时,...

回答 2 投票 0

我想在 C# 中的表单应用程序中复制项目

我想创建另外 2 个文本框,就像附图中的那样。有没有办法复制这些项目并过去,因为它们只是更改名称?或者我怎样才能创建相同的...

回答 1 投票 0

(CSS新手)文本框消失,图像变得混乱

我正在学习使用超级基本的 CSS 制作一个网页,应该如下所示: 我把班级名称写成红色 但当我输入代码时,是这样的: 我正在学习使用超级基本的 CSS 制作一个网页,应该如下所示: 但是当我输入代码时,是这样的: <!DOCTYPE html> <html lang="es-ES"> <html> <head> <title>2do parcial PROYECTO</title> <style> h1{ text-align:center; background-color:violet; border-width: 2px; } p.cul{ text-align: center; font-family: Aharoni; font-size: 35px; background-color:violet; border-style: dotted; border-width: 2px; width: 1050px; } div{ float:left; background-color: lightcyan; width: 200px; border: 15px solid red; padding: 25px; margin: 15px; } img{ float:middle; } div.one{ float:right; background-color: lightcyan; width: 330px; border: 15px solid red; padding: 25px; margin: 15px; } p{ float:left; background-color:lightcyan; width:782px; } img.one{ float:right; } p.dep{ text-align:center; font-family:Aharoni; font-size:35px; width:1050px; background-color:violet; border-style: dotted; border-width: 2px; } div.cuadrote{ float:left; position: absolute; right: %100; bottom: 800px; background-color: lightcyan; width: 200px; border: 15px solid red; padding: 25px; margin: 15px; } img.batorojo{ position: absolute; right:570px; bottom: -394px; } } div.cuadrito{ vertical-align:middle; background-color: lightcyan; border: 15px solid red; padding: 25px; margin: 15px; } img.caribe{ float:right; position: absolute; right:35px; bottom:-360px; } p.blueboxie{ background-color:lightcyan; float:left; width: 1000px; } </style> </head> <body> <h1>Evaluacion 2</h1> <p class="cul">Eventos culturales</p> <div>&#161;NUEVOS CURSOS CULTURALES EN CEART DISPONIBLES&#33;Se cuentan con clases de: *Artes plasticas(Lunes,miercoles y viernes de 5:00 a 6:30pm) *Ballet(Lunes,miercoles y viernes de 7:30 a 9:00pm) *Violin(Martes y jueves de 9:00 a 11:00am)</div> <img src="http://mexicali.org/wp-content/uploads/2012/08/Centro-Estatal-de-las-Artes.jpg" alt="x" width=300 height=200> <div class="one">Se anuncian proximamente funciones de teatrales de obras de shakespeare en el teatro del estado, entre ellas se encuentran desde clasicos como Hamlet o Romeo y Julieta hasta los escritos mas rec&oacute;nditos del autor ya mencionado.Puedes conseguir entradas en ticketmaster.com o comprarlas en la taquilla del teatro a partir del 10 de abril.Informes o dudas al (686)111-1111</div class="one"> <p>Con un festival artístico-cultural el Instituto Municipal de Arte y Cultura de Mexicali (IMACUM) conmemorará el 42 aniversario luctuoso del legendario compositor y cantante José Alfredo Jiménez. El evento tendrá lugar en las instalaciones de la Casa de la Cultura de la Juventu (CREA Cultura) este sábado 21 de noviembre, y para ello se han organizado una serie de actividades gratuitas para el goce de los mexicalenses. A las 7:00 p.m. en la Galería-Vestíbulo se inaugurará la exposición colectiva “Nomás nuestro amor”, en la que participan artistas gráficos, plásticos e ilustradores, entre ellos Gabriela Badilla, Odette Barajas, Gabriela Buenrostro, Luis Felipe Vargas Brownell, Fernando Corona, Aída Corral, Carlos Cortez, Mara Leticia Dorantes, Roberto Figueroa, Gloria Gachuz, Marco Manríquez, Pablo Martínez, Rogelio Pérezcano, Natalia Rojas, Karla Sánchez, y Karina Venegas. Estos artistas tomaron el nombre de una canción de José Alfredo para de ahí generar su pieza con libertad de creación, lo que el público mexicalense podrá observar una gran variedad de propuestas en cuanto a trabajo, técnica y colorido.</p> <img class="one" src="http://www.zonalider.com/sites/default/files/styles/scale_max_width_auto_height/public/article/image/jose_alfredo_jimenez.jpg?itok=9cZnT7Ir" alt="x" width=250 height=200></img> <p class="dep">Eventos deportivos</p class="dep"> <div class="cuadrote">&#191;SAB&Iacute;AS QUE&#63;...El juego de béisbol más Largo tuvo lugar en el año 1981, en las Ligas Menores donde se jugaron 33 entradas. Se enfrentaban Rochester (NY) Red Wings contra Pawtucket (RI) Red Sox. Al entrar en la entrada número 21 el juego seguía empatado 2-2 y fue suspendido. Dos meses después el juego se reasignó y en 18 minutos el Pawtucket anotó la carrera del gane.</div> <img class="batorojo" src="http://allswalls.com/images/boston-red-sox-baseball-mlb-k-wallpaper-1.jpg" alt="x" width=200 height=170></img> <div class="cuadrito">Respecto al base ball se encuentra proximamente la variedad de juegos de la serie del caribe, incluyendo duelos epicos como el de CUBA vs HAITI , ¡No te los puedes perder!</div> <img class="caribe" src="" alt="x" width=200 height=170></img> <p class="blueboxie">&#161;SE LE CHISPOTEO&#33;GUADALAJARA, JALISCO (02/ABR/2017).- El Zorro es de los pocos animales capaces de tropezar con la misma piedra dos veces. Anoche, Matías Alustiza había tenido una noche de ensueño. Dos goles suyos tenían al Atlas en la pelea en el partido y en el Clausura 2017. A dos minutos del final el argentino puso la pelota en el manchón penal por segunda vez en el juego. En sus pies tenía la victoria que colocaba a los tapatíos en zona de Liguilla. Alustiza cobró el penalti que representaba la victoria igual que el penalti que representó en su momento el empate a tres. Un disparo con mucha dosis de humillación al arquero. Gibrán Lajud adivinó la intención del argentino y no se dejó sobajar una segunda vez. Recostó a su derecha y se quedó con la pelota y con el punto para su equipo. Sí, Alustiza hizo un “Ponchito” González y el Atlas empató 3-3 un juego que debía y tenía que ganar.</p> </body></html> 顶部一切看起来都正常,但页面底部缺少文本框“cuadrote”,并且图像被重新分配。昨天我还使用了命令位置(谷歌搜索,我真的不知道它是如何工作的)来修复图像,但它们再次变得混乱。 非常漂亮,请帮我,这是今天到期的学校项目 您的代码有些混乱,这可能听起来无关,但如果有人提供帮助,它可能会加快速度。 为什么要关闭包含类的标签? 仅举几例: <p class="dep">...</p class="dep"> <div class="cuadrote">....</div class="cuadrote"> <img class="caribe" src="" alt="x" width=200 height=170></img class="caribe"> 用途: <p class="dep">...</p>

回答 1 投票 0

SetFocus 在文本框的用户窗体中没有效果

我有一个带有日期文本框的用户窗体。退出时,我想测试输入的值是否为日期,如果不是,则会弹出一个消息框,通知该条目无效。这一切都很好。 但我...

回答 1 投票 0

Python 出现 KeyError 问题:当数据不在 json 中时跳过错误?

长时间来电者第一次聆听;) 对待我就像我 5 岁一样,我对 python 脚本非常陌生,并且在调用 API 然后在简单的

回答 1 投票 0

如何在VB.NET中通过数据表将一个文本框拆分为多列datagridview

我正在尝试通过VB.NET中的数据表将一个文本框拆分为多列datagridview。 所以我通过文本框中的事件制作了带有 QR 条形码标签的 2D 条形码扫描仪。 有什么问题吗...

回答 1 投票 0

如何在 C# Windows 窗体应用程序中激活拼写检查?

我正在 Visual Studio 2012 中制作 C# Windows 窗体应用程序。我想添加一个具有拼写检查功能的文本框。能解释一下具体流程吗?

回答 5 投票 0

Bunifu 控件问题:UseSystemPasswordChar 影响占位符文本

我在 VB.NET 应用程序中遇到了 Bunifu 控件的意外行为。具体来说,当我将 Bunifu TextBox 的 'UseSystemPasswordChar' 属性设置为 True 时,它不仅取代...

回答 1 投票 0

如何使用 MS Access 数据库在文本框中显示数据

我正在尝试将数据库中的用户数据显示到文本框中,以便用户稍后可以编辑/更新该数据。 我收到的错误是没有为至少一个所需参数设置任何值。 我会...

回答 2 投票 0

在 WPF XAML 中将焦点设置在 TextBox 上

尽管此论坛和其他论坛上有一些帖子,但我找不到告诉我如何将焦点设置在文本框上的内容。 我有一个带有许多标签和文本框的用户控件。加载表单后,我...

回答 10 投票 0

我想在文本框悬停时在其底部显示一条线

所以基本上我想实现悬停效果,该效果将是文本框底部出现一条线,该线的宽度必须是文本框实际宽度的一半。 如果可以的话...

回答 1 投票 0

如何在Delphi TEdit中隐藏插入符号?

我想从 Delphi 中的 TEdit 控件中删除插入符号。我已将组件设置为 Enabled := False 但插入符号仍然出现。 我的问题是如何从禁用的 TEdit 续集中删除插入符号...

回答 3 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.