当前位置:编程学习 > C#/ASP.NET >>

这种表格怎么实现?


--------------------编程问答-------------------- 主要是颜色一列 --------------------编程问答-------------------- DataGridView装入图片(图片可以现画) --------------------编程问答--------------------
引用 2 楼 caozhy 的回复:
DataGridView装入图片(图片可以现画)

用DevExpress控件的话,有哪些可以 --------------------编程问答--------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            dataGridView1.AllowUserToAddRows = false;
            var c1 = new DataGridViewTextBoxColumn();
            c1.HeaderText = "属性";
            var c2 = new DataGridViewImageColumn();
            c2.HeaderText = "颜色";
            dataGridView1.Columns.Add(c1);
            dataGridView1.Columns.Add(c2);
            var row1 = new DataGridViewRow();
            row1.Cells.Add(new DataGridViewTextBoxCell());
            row1.Cells.Add(new DataGridViewImageCell());
            row1.Cells[0].Value = "Red";
            row1.Cells[1].Value = CreateImage(Color.Red);
            dataGridView1.Rows.Add(row1);
            var row2 = new DataGridViewRow();
            row2.Cells.Add(new DataGridViewTextBoxCell());
            row2.Cells.Add(new DataGridViewImageCell());
            row2.Cells[0].Value = "Blue";
            row2.Cells[1].Value = CreateImage(Color.Blue);
            dataGridView1.Rows.Add(row2);
        }

        private Image CreateImage(Color color)
        {
            Bitmap bmp = new Bitmap(100, 20);
            var g = Graphics.FromImage(bmp);
            g.FillRectangle(new SolidBrush(color), 0, 0, bmp.Width, bmp.Height);
            return bmp;
        }
    }
}


在窗体上放一个DataGridView,双击窗体,在Form_Load中添加上述代码。

运行 --------------------编程问答--------------------
引用 3 楼 tcziflw2010 的回复:
Quote: 引用 2 楼 caozhy 的回复:

DataGridView装入图片(图片可以现画)

用DevExpress控件的话,有哪些可以


思路类似。只要支持图片列。 --------------------编程问答-------------------- 自绘DataGridView
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,