小编Car*_*rlo的帖子

将e.NewValue转换为十进制

我正在尝试处理价值变化,所以我可以进行计算

    private void supplierDiscountPercetangeSpinEdit_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
    {
        decimal price, percentage, calculatedPrice;

        price = (decimal)supplierPriceSpinEdit.EditValue;
        percentage = Convert.ToDecimal(e.NewValue);  // breakpoint 1
        calculatedPrice = Popust.Izracunaj(price, percentage); // breakpoint 2

        supplierPriceWithDiscountSpinEdit.EditValue = calculatedPrice;
    }
Run Code Online (Sandbox Code Playgroud)

在Breakpoint 1 e.NewValueobject {string} "1.00"

在Breakpoint 2 percentageobject {decimal} 100

它必须是 1.00M

我怎样才能转换e.NewValue为十进制?

.net c# decimal

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

c#dispose - 这是对的吗?

这是处理和使用的正确方法吗?

public partial class Form1 : Form
{
    winappContext _context;
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        using (_context = new winappContext())
        {
            _context = new winappContext();
            var query = from c in _context.Customers
                        orderby c.CustomerName
                        select c;

            this.customerBindingSource.DataSource = query.ToList();
        }
....
Run Code Online (Sandbox Code Playgroud)

或者我需要调用_context.Dispose()onFormClosing

谢谢

.net c#

0
推荐指数
1
解决办法
118
查看次数

标签 统计

.net ×2

c# ×2

decimal ×1