c# - 为什么这个 DataGridView 单元格格式错误?
问题描述
我有一个 DataGridView,并且我有一些如下所示的列代码:
private void dataGridView2_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
DataGridViewLinkCell cell = new DataGridViewLinkCell();
cell.LinkColor = Color.Blue;
cell.VisitedLinkColor = Color.Blue;
foreach(DataGridViewRow r in dataGridView2.Rows)
{
r.Cells["url"] = cell;
}
}
我也有一些看起来像这样的双击代码:
private void dataGridView2_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView2.Columns[dataGridView2.CurrentCell.ColumnIndex].HeaderText.Contains("URL"))
{
if (!String.IsNullOrWhiteSpace(dataGridView2.CurrentCell.EditedFormattedValue.ToString()))
{
System.Diagnostics.Process.Start("http://" + dataGridView2.CurrentCell.EditedFormattedValue);
}
}
}
现在,在本专栏中,我双击具有http://aweber.com内容的单元格。我的笔记本电脑将我带到我的浏览器,但出现一个页面,说它在查找文件时遇到问题。我查看浏览器的地址栏,找到 http//aweber.com(没有冒号)。
为什么要切除结肠?
解决方案
你可以试试这个
System.Diagnostics.Process.Start($"{dgv.CurrentCell.EditedFormattedValue}");
推荐阅读
- scala - 如何在函数中平面嵌套元组参数?
- c++ - 自动对象的重写析构函数是否定义良好?
- python - 为什么我的 exit() 命令在 python 中不起作用?
- flutter - Flutter 小部件继承与组合
- architecture - 微服务 BFF 模式
- regex - 如何使用 REGEXP_REPLACE 替换特定条件下的重复单词?
- javascript - 从复杂的 JSON 中提取值
- javascript - react - 弹性容器外的弹性项目
- python - 从linux中的json文件中删除特定数据
- python-3.x - 无法找到我的 CNN 模型的准确度和 ROC 曲线