在运行时更改datagridview列类型 [英] changing datagridview column type at runtime

查看:91
本文介绍了在运行时更改datagridview列类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据特定条件在运行时将datagridview列中的单元格类型从textbox更改为button。  这是我目前要更改的代码。  

I am trying to change the cell type in a datagridview column from textbox to button at runtime based on certain criteria.  This is my code for changing at the moment.  

datagridview.Columns.RemoveAt(1); datagridview.Columns.Insert(1, new DataGridViewButtonColumn()); LicenceList.Columns[1].Name = "ExpiredDate"; datagridview.Columns[1].DefaultCellStyle.Font = new Font("Times New Roman", 12, FontStyle.Bold); datagridview.Columns[1].DefaultCellStyle.ForeColor = Color.Red; datagridview.Rows[x].Cells[1].Value = Date;

推荐答案

嗨理查德,

您没有指明您所面临的问题。你的代码看起来不错。它正在删除TextBox列并在该位置添加Button列。

You didn't specify the issue you are facing. Your code looks good to me. It is removing the TextBox column and adding the Button column at that position.

请发布您遇到的问题吗?

Could please post the issue you are having?


这篇关于在运行时更改datagridview列类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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