DataGridView 单元格中内容为链接,字体为蓝色

本文介绍了如何在C#的DataGridView控件中设置单元格内容为蓝色超链接,提供了一种增强表格数据展示的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

		this.PictureDataGridView.Columns[0].HeaderText = "编号";//第一列title
                this.PictureDataGridView.Columns[1].HeaderText = "元件名称";//第二列title
                this.PictureDataGridView.Columns[2].HeaderText = "查看图片";//第三列title
                this.PictureDataGridView.Columns[2].DataPropertyName = "pRemarks";//第三列数据对应数据库字段名
                this.PictureDataGridView.Columns[2].Visible = false;//设置第三列为不可见
                DataGridViewLinkColumn links = new DataGridViewLinkColumn(); //列属性为链接的实例化
                links.HeaderText = "查看图片";//title
                links.DataPropertyName = "pRemarks";//对应数据库中的字段名
                links.ActiveLinkColor = Color.White;//点击后链接字体为白色
                links.LinkBehavior = LinkBehavior.SystemDefault;
                links.LinkColor = Color.Blue;//链接为蓝色
                links.TrackVisitedState = true;
                links.VisitedLinkColor = Color.YellowGreen;//访问链接后字体颜色为黄绿色
                links.Width = 150;//cell的宽
                this.PictureDataGridView.Columns.Add(links);//将链接实例添加进列


结果显示

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值