格式化dataGridview里数据

private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)

        {

            DataGridView dgv = (DataGridView)sender;

            if (e.RowIndex < dgv.Rows.Count - 1)//这个判断,如果DataGridView没有设置为添加.就可以不要了          

            {



                if (e.ColumnIndex == 4)

                {

                    e.Value = ps.订单的评价状态(e.Value.ToString());

                    //e.CellStyle.ForeColor = Color.Green;

                }

                else if (e.ColumnIndex == 15)

                {

                    e.Value = ps.运送类型(e.Value.ToString());

                    //e.CellStyle.ForeColor = Color.Green;

                }



                //else if (e.ColumnIndex == 19)

                //{

                //    e.Value = ps.运送类型(e.Value.ToString());

                //    //e.CellStyle.ForeColor = Color.Green;

                //}

            }

        }

你可能感兴趣的:(datagridview)