-
触发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));
- }
- }
- }
-
相关阅读:
【第4题】 什么是https
【第3题】 两个队列生成一个栈
【第2题】 链表的逆置
【第1题】 Pythonn内存管理以及垃圾回收机制
tmunx error:invalid option: status-utf8 invalid option: utf8
ubuntu install google-chrome-stable
使用pyenv安装多个Python版本
Linux命令行烧录树莓派镜像至SD卡
freenode configuration sasl authentication in weechat
尝试IRC & freenode
-
原文地址:https://www.cnblogs.com/YuanDong1314/p/9189767.html
Copyright © 2020-2023
润新知