[英]how to copy a masked password to another textbox and convert it to text
我对此有些陌生,我只是想知道这是否有可能。
我有两个文本框,其中第一个文本框的文本设置为bullet,而另一个文本框为纯文本。 我也有复选框,因此无论何时我想不显示密码,我都可以切换它们。
问题是,如何将屏蔽的密码从一个文本框复制到另一个文本框,并将其转换为纯文本,反之亦然?
一种方法是在两个文本框中始终使用相同的文本。 当用户在第一个数字中输入数字时,第二个数字也会随之变化。
就像是:
<Window x:Class="WpfStaff.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid >
<TextBox Name="txt1" HorizontalAlignment="Left" Height="23" Margin="122,123,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="165" TextChanged="TextBox_TextChanged" />
<TextBox Name="txt2" HorizontalAlignment="Left" Height="23" Margin="122,163,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="165" />
</Grid>
using System.Windows;
using System.Windows.Controls;
namespace WpfStaff
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
txt2.Text = txt1.Text;
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
if(txt2!= null)
txt2.Text = (sender as TextBox).Text;
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.