Excel工作表在网格视图VS Windows应用程序中上载 [英] Excel sheet Upload in Grid View VS windows application

查看:77
本文介绍了Excel工作表在网格视图VS Windows应用程序中上载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我在我的Windows应用程序网格视图中上传了一个excel,但我的问题是在一列中,值是1234.8但我想显示为1234.80我该怎么做才能帮助我



这里excel中的列是通用格式,我现在将它加载到网格视图上我的意图是修改网格视图中的特定列,所以它应该在小数点后显示2位数

Hi All
I uploading an excel in my windows application Grid View but my question is in one column values are like 1234.8 but I want to show like 1234.80 how can I make this please help me

Here the column in the excel is general format and I loaded it on Grid View now my Intention is modify the particular column in Grid View so it should display 2 digit after decimal

推荐答案

试试这可以解决你的问题。



Try this it can solve your problem.

private void Form1_Load(object sender, EventArgs e)
        {
            dataGridView1.DataSource = dtGetData();
            dataGridView1.Columns["Salary"].DefaultCellStyle.Format = "0.00##";
        }

        public DataTable dtGetData()
        {
            SqlConnection con = new SqlConnection(ConString);
            con.Open();
            SqlCommand cmd = new SqlCommand("select * from Employee", con);
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            return dt;
        }


这篇关于Excel工作表在网格视图VS Windows应用程序中上载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆