-
触发DataGridView的CellClick事件
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
-
-
- namespace WindowsFormsApplication2
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
-
-
- private void Form1_Load(object sender, EventArgs e)
- {
- DataTable dt = new DataTable();
- dt.Columns.Add("ID");
- dt.Columns.Add("Name");
- dt.Columns.Add("Age");
- for (int i = 0; i < 5; i++)
- {
- dt.Rows.Add();
- dt.Rows[i][0] = i;
- dt.Rows[i][1] = i.ToString() + "Name";
- dt.Rows[i][2] = (i + 1) * 5;
- }
-
-
- dataGridView1.DataSource = dt;
- }
-
-
-
-
- private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
- {
- MessageBox.Show(e.RowIndex.ToString() + ":" + e.ColumnIndex.ToString());
- }
-
-
- private void button1_Click(object sender, EventArgs e)
- {
-
- dataGridView1_CellClick(dataGridView1, new DataGridViewCellEventArgs(dataGridView1.SelectedCells[0].ColumnIndex, dataGridView1.SelectedCells[0].RowIndex));
- }
- }
- }
-
相关阅读:
bzoj1878: [SDOI2009]HH的项链
bzoj1053: [HAOI2007]反素数ant
bzoj2456: mode
bzoj2330: [SCOI2011]糖果
bzoj1050: [HAOI2006]旅行comf
bzoj1047: [HAOI2007]理想的正方形
bzoj1968: [Ahoi2005]COMMON 约数研究
bzoj1046: [HAOI2007]上升序列
bzoj2440: [中山市选2011]完全平方数
bzoj1202: [HNOI2005]狡猾的商人
-
原文地址:https://www.cnblogs.com/YuanDong1314/p/9189767.html
Copyright © 2020-2023
润新知