<pre name="code" class="csharp"> /// <summary>
/// 单击DataGridView中的单元格,在文本框中显示单击的信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if(e.RowIndex>0)
{
txtName.Text = dgvManager.CurrentRow.Cells[2].Value.ToString();
txtDirector.Text = dgvManager.Rows[e.RowIndex].Cells["Movie_Director"].Value.ToString();
DateTime datetoDay = new DateTime().Date; //new一个时间对象 目的是将电影发行时间的小时,分和秒给去掉 保留到最小单位为日
datetoDay = Convert.ToDateTime(dgvManager.Rows[e.RowIndex].Cells["Data_Released"].FormattedValue);//将当前行的日期单元格的值 赋给 时间对象datetoDay
DataGridView初始化——添加列、添加行号、连接数据库、单击单元格在文本框中显示
最新推荐文章于 2022-08-07 18:41:52 发布