【问题标题】:displaying the square root of "X" in label在标签中显示“X”的平方根
【发布时间】:2021-12-21 01:48:47
【问题描述】:

我用 C# 编写了一个简单的计算器程序,它也可以计算任何数字的平方根。

所以,我只是想知道您是否可以在标签中显示所述数字。或者更确切地说,就像在实际数学中计算数字在平方根以下时那样显示它

(https://images-na.ssl-images-amazon.com/images/I/51Vo0t5w5YL.jpg).

这还有可能吗?对于那些好奇的人:


//Root
if (CW3.Checked) //Square Root Box checked
{
    if (Z3N.Checked) //Negativ Number Box checked
    {
        MessageBox.Show("You can't get the square root of negative numbers.");
    }
    else
    {
        Zahl3 = Math.Sqrt(Zahl3);
    }
}

【问题讨论】:

标签: c# math label square-root


【解决方案1】:

听起来这只是一个小项目,所以也许你可以使用这样的东西:

<Grid HorizontalAlignment="Center">
    <Label Content="13.2" HorizontalAlignment="Left" VerticalAlignment="Center"/>
    <Label Content="√" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="18" Margin="-11,-2,0,0"/>
    <Grid Height="1" Background="Black" Margin="3,-13,3,0"/>
</Grid>

只需将其全部复制并插入,而不是您拥有的标签。并更改数字 - 绑定内容或从后面的代码编辑或您所做的任何事情。边距可能有些烦躁,但这都是乐趣的一部分。不过,TextBlocks 可能是替代标签的方式。

【讨论】:

    猜你喜欢
    • 2017-03-12
    • 1970-01-01
    • 2021-01-06
    • 2021-01-04
    • 1970-01-01
    • 2019-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多