使用按钮单击更改datagridview中列的数据类型

问题描述

我想根据需要更改column的数据类型。 表示我想将十进制更改为字符串还是将int更改为字符串,反之亦然。 实际上,我已经创建了一个列表,其中有5列。 目前,它工作正常。但我的要求是我想在序列号列中添加数据,其余应为空。我尝试了几种选择,但失败了。当我尝试添加时,它会添加到列中,但其余列会自动填充0,并且我不想添加零。

FOR DETAILED REQUIREMENT REFER TO IMAGE

使用系统; 使用System.Collections.Generic; 使用System.ComponentModel; 使用System.Linq; 使用System.Text; 使用System.Threading.Tasks;

 namespace WindowsFormsApp1.Models
{
public class CartItem
{
    // [displayName("Sl no.")]
    //public string SerialNumber { get; set; }

    [displayName("Product Name")]
    public string ProductName { get; set; }

    [displayName("Serial No")]
    public string HSNCode { get; set; }

    public int Quantity { get; set; }

    public decimal Rate { get; set; }

    [displayName("Total Price")]
    public decimal TotalPrice { get; set; }
    
    
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)