help!!!

爱篮球的小码农 2012-04-25 07:34:19
需要动态设置datagridview里一列单元格的类型 如从linklabel 变成 textbox 、、、so what should i do?
...全文
149 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 的回复:]

C# code

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;

usin……
[/Quote]


恩 好的谢谢了。。
旅行着 2012-04-28
  • 打赏
  • 举报
回复
没看懂这是用的什么语言呀?
  • 打赏
  • 举报
回复
弄两列,隐藏一列。
意飞翔心飞扬 2012-04-28
  • 打赏
  • 举报
回复

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;

using System.Data.Odbc;

namespace WinForm
{
public partial class frmReport : Form
{
public frmReport()
{
InitializeComponent();
}

private void frmReport_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = AddData();
}

private DataTable AddData()
{
string strsql = "select * from navverchgrec";
OdbcConnection conn = new OdbcConnection("Dsn=PostgreSQLTighten;");
DataSet ds = new DataSet();

try
{
conn.Open();
OdbcDataAdapter dat = new OdbcDataAdapter(strsql, conn);
dat.Fill(ds);

return ds.Tables[0];
}
catch (Exception)
{
return null;
}
finally
{
conn.Close();

dataGridView1.Columns["aaa"].Visible = false;
}
}

private void button1_Click(object sender, EventArgs e)
{
dataGridView1.Columns["aaa"].Visible = !dataGridView1.Columns["aaa"].Visible;
dataGridView1.Columns["versionname"].Visible = !dataGridView1.Columns["versionname"].Visible;
}
}
}



我写了一个,你试试啊。反正效果出来了。
fanbingyuan 2012-04-28
  • 打赏
  • 举报
回复
bs上有种是挂个textbox 鼠标点击的时候就把这个textbox移动过去 覆盖,赋值,
cs的 可以借鉴不?
意飞翔心飞扬 2012-04-28
  • 打赏
  • 举报
回复
[Quote=引用楼主 的回复:]
需要动态设置datagridview里一列单元格的类型 如从linklabel 变成 textbox 、、、so what should i do?
[/Quote]
我有个思路,你可以设置两列,一列是linklabel一列是textbox,用哪个,让哪个显示,你看行不行。
xb12369 2012-04-28
  • 打赏
  • 举报
回复
textbox txt = this.datagridview.cell.findcontroll["**"] as textbox;
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

不知道你是想怎么个动态法,不过这个可以在前台用javascript来实现,但是具体怎么弄,还要看你到底想干嘛
[/Quote]


就是吧 本来它是手动设置一列的linklabel 现在我需要用代码去把它修改成textbox 值当然不变
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

楼上的方法不行 因为楼主是winform的,
[/Quote]

对的 。。。winform
orochiheart 2012-04-25
  • 打赏
  • 举报
回复
楼上的方法不行 因为楼主是winform的,
jakecheng 2012-04-25
  • 打赏
  • 举报
回复
不知道你是想怎么个动态法,不过这个可以在前台用javascript来实现,但是具体怎么弄,还要看你到底想干嘛

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧