要求鼠标点击到DataGrid中的行时,将DataGrid中每一列的数据放到窗体中相应的TextBox中?没找到像这样的事件啊。
解决方案 »
- ()=>obj.PropertyName转换成delegate描述的话应该是怎样子?
- vs2008安装出错的问题,求助达人,在线等!
- 我用asp.net ajax XMLHTTP返回responseText时,大家同样用IE6,但有的机显示乱码,有的显示正常,不知为何?
- 50分求一个小的投票系统,类似搜狐
- abstract 可以和 override 一起使用吗?
- 怎样用XMLHTTP无刷新获取开奖信息,像时时彩基地一样。
- 在线等!!Graphics g = Graphics.FromImage(bmp);对象在其他地方使用异常
- 正则表达式如何取一段文本中的两个部份?
- C# combobox绑定数据库表,空值行如何去掉?
- 在C#中怎样才能获取摄像头的视频
- treeview生成数据库
- 一个数字超过64位了,怎么计算啊
把每个字段取出添到textBox
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
DataBind();
}
private void DataBind()
{
SqlConnection con = new SqlConnection("server=.;database=student;uid=sa;pwd=0421");
SqlDataAdapter sda = new SqlDataAdapter("select sno,sname,sage from studentDetails", con);
sda.Fill(ds, "student");
//数据绑定
this.dataGridView1.DataSource = ds.Tables["student"];
this.textBox1.DataBindings.Add("Text", ds.Tables["student"], "sno");
this.textBox2.DataBindings.Add("Text", ds.Tables["student"], "sname");
this.textBox3.DataBindings.Add("Text", ds.Tables["student"], "sage"); }
private void button1_Click(object sender, EventArgs e)
{
//前一个
this.BindingContext[ds.Tables["student"]].Position += 1;
}
private void button2_Click(object sender, EventArgs e)
{
//后一个
this.BindingContext[ds.Tables["student"]].Position -= 1;
}
这是绑定吧?
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
DataBind();
}
private void DataBind()
{
SqlConnection con = new SqlConnection("server=.;database=student;uid=sa;pwd=0421");
SqlDataAdapter sda = new SqlDataAdapter("select sno,sname,sage from studentDetails", con);
sda.Fill(ds, "student");
//数据绑定
this.dataGridView1.DataSource = ds.Tables["student"];
this.textBox1.DataBindings.Add("Text", ds.Tables["student"], "sno");
this.textBox2.DataBindings.Add("Text", ds.Tables["student"], "sname");
this.textBox3.DataBindings.Add("Text", ds.Tables["student"], "sage"); }
private void button1_Click(object sender, EventArgs e)
{
//前一个
this.BindingContext[ds.Tables["student"]].Position += 1;
}
private void button2_Click(object sender, EventArgs e)
{
//后一个
this.BindingContext[ds.Tables["student"]].Position -= 1;
}你可以在cellclick事件中
写下把当前行的资料付给text
DataGridViewRow rowLED = dataGridViewLED.CurrentRow;
this.txtLEDID.Text = rowLED.Cells[0].Value.ToString();
this.txtLEDNportIP.Text = rowLED.Cells[1].Value.ToString();
this.txtLEDPortName.Text = rowLED.Cells[2].Value.ToString();
this.txtLEDStationNO.Text = rowLED.Cells[3].Value.ToString();
this.numericUpDownLEDLight.Value = Convert.ToDecimal(rowLED.Cells[4].Value);
this.numericUpDownLEDScreenLength.Value = Convert.ToDecimal(rowLED.Cells[5].Value);
this.numericUpDownLEDSpeed.Value = Convert.ToDecimal(rowLED.Cells[6].Value);
this.numericUpDownLEDStoptime.Value = Convert.ToDecimal(rowLED.Cells[7].Value);
this.cobINFashion.SelectedValue = rowLED.Cells[8].Value.ToString();
this.cobOUTFashion.SelectedValue = rowLED.Cells[9].Value.ToString();