using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Drawing;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication1
{
public partial class 选择导师列表 : Form
{
SQL.connect c_sql = new SQL.connect();
public 选择导师列表()
{
InitializeComponent();
}
private void 选择导师列表_Load(object sender, EventArgs e)
{
table();
}
public void table()
{
string sql = "select * from 老师信息";
IDataReader dq = c_sql.read(sql);
while (dq.Read())
{
dataGridView1.Rows.Add(dq[0].ToString(), dq[2].ToString(), dq[5].ToString())
;
}
dq.Close();
c_sql.connectclose();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
SQL.connect c_sql = new SQL.connect();
int idx = dataGridView1.CurrentCell.RowIndex;
int choice;
TextBox selected = selected_box(out choice);
selected.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
}
private TextBox selected_box(out int choice)
{
TextBox selected;
if (radioButton1.Checked)
{ selected = textBox1; choice = 1; }
else if (radioButton2.Checked)
{ selected = textBox2; choice = 2; }
else
{ selected = textBox3; choice = 3; }
return selected;
}
private void button3_Click(object sender, EventArgs e)
{
导师双选系统学生界面 frm = new 导师双选系统学生界面();
frm.Show();
this.Visible = false;
}
}
}
预期就是点击radioButton1,在点击GridView的某一行,其内的ID会显示在textbox1里面
抱歉,您给的代码暂时不能判断是哪里出现了问题。
一些建议:不要在可编码的部分写中文。想要完成上述动作的话,用Private Int32 去记录一些值。当这些值全部符合情况的时候,在OnClick事件中触发一些功能。
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632