相关疑难解决方法(0)

检查TextBox是否为空并返回MessageBox?

我做了这个语句来检查TextBox是否为空,但MessageBox总是显示TextBox是否为空.

    private void NextButton_Click(object sender, EventArgs e)
    {
        decimal MarkPoints, x, y;
        x = HoursNumericUpDown.Value;
        y = MarkNumericUpDown.Value;
        MarkPoints = x * y;

        //decimal MarkPoints = (decimal)HoursNumericUpDown.Value * (decimal)HoursNumericUpDown.Value;


        DataGridViewRow dgvRow = new DataGridViewRow();
        DataGridViewTextBoxCell dgvCell =  new DataGridViewTextBoxCell();

        dgvCell = new DataGridViewTextBoxCell();
        dgvCell.Value = MaterialTextBox.Text;
        dgvRow.Cells.Add(dgvCell);

        dgvCell = new DataGridViewTextBoxCell();
        dgvCell.Value = HoursNumericUpDown.Value;
        dgvRow.Cells.Add(dgvCell);

        dgvCell = new DataGridViewTextBoxCell();
        dgvCell.Value = MarkNumericUpDown.Value;
        dgvRow.Cells.Add(dgvCell);

        dgvCell = new DataGridViewTextBoxCell();
        dgvCell.Value = MarkPoints;
        dgvRow.Cells.Add(dgvCell);

        dataGridView1.Rows.Add(dgvRow);

        MaterialTextBox.Clear();
        HoursNumericUpDown.Value = HoursNumericUpDown.Minimum;
        MarkNumericUpDown.Value = MarkNumericUpDown.Minimum;

        if …
Run Code Online (Sandbox Code Playgroud)

c# textbox winforms

20
推荐指数
3
解决办法
24万
查看次数

空文本框是空字符串还是null?

有问题的文本框涉及我的代码中的if语句,这是有效的

if (textbox.text != "") 
{
    do this
}
Run Code Online (Sandbox Code Playgroud)

我很好奇,如果一个空文本框将被视为空字符串或空语句.

.net c# asp.net null

14
推荐指数
1
解决办法
7万
查看次数

此XAML代码中的IsEmpty引用/成员在哪里?

我无法理解IsEmpty这段代码(Path=Text.IsEmpty)(来自水印TextBox)的来源:

<Grid Grid.Row="0" Background="{StaticResource brushWatermarkBackground}" 
                   Style="{StaticResource EntryFieldStyle}" >
    <TextBlock Margin="5,2" Text="Type to search ..." Foreground="Gray"
               Visibility="{Binding ElementName=entry, Path=Text.IsEmpty, 
                          Converter={StaticResource BooleanToVisibilityConverter}}"/>
    <TextBox Name="entry" Background="Transparent"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)

你可以看到一个字符串没有任何IsEmpty属性.A DependencyProperty也没有任何IsEmpty成员.我甚至尝试在IsEmpty对象浏览器窗口中搜索,但没有任何相关结果解释代码.

你能解释一下IsEmpty这里的参考吗?(关于它的任何参考链接都很棒).

谢谢!

.net c# wpf xaml

9
推荐指数
1
解决办法
1446
查看次数

WPF TextBox中的帮助文本在第一次输入后消失 - 水印,XAML方式

在WPF TextBox中,我想提供在第一次输入后消失的描述.这应该为用户提供一些帮助,他应该在文本字段中输入什么.

可以使用Label在给定的TextBox上方显示文本.我对一个例子感兴趣,但找不到任何例子.理想情况下,解决方案仅适用于XAML.

wpf xaml textbox

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×3

.net ×2

textbox ×2

wpf ×2

xaml ×2

asp.net ×1

null ×1

winforms ×1