当前位置:网站首页>C# 窗体应用使用对象绑定 DataGridView 数据绑定
C# 窗体应用使用对象绑定 DataGridView 数据绑定
2022-07-28 08:58:00 【InfoQ】
第一步 创建窗体文件
第二步 创建成功窗体文件展示
第三步 对工具箱处理
第四步 创建DatagridView控件
第五步 创建类库
第六步 创建类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApp2
{
class Class1
{
private int id;
private string name;
private string age;
public Class1()
{
}
public int Id { get => id; set => id = value; }
public string Name { get => name; set => name = value; }
public string Age { get => age; set => age = value; }
}
}
复制代码
第七步 引用类库的类
第八步 代码和效果展示
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Class1 c1 = new Class1();
c1.Id = 1;
c1.Name = "IC00";
c1.Age = "18";
List<Class1> list = new List<Class1>();
list.Add(c1);
dataGridView1.DataSource = list;
}
}
}
复制代码
总结:
边栏推荐
- 2022年危险化学品经营单位安全管理人员上岗证题目及答案
- Oracle creates users with query permission only
- c# 有符号和无符号字节变量
- 2022牛客多校第一场补题
- golang升级到1.18.4版本 遇到的问题
- Personal blog applet
- 2022 examination question bank and simulation examination of crane driver (limited to bridge crane)
- MATLAB的符号运算
- JDBC connection database
- [vscode] vscode usage
猜你喜欢

2022 high voltage electrician examination simulated 100 questions and simulated examination

MQTT. JS introductory tutorial: learning notes

51 single chip microcomputer storage: EEPROM (I2C)

Activiti startup error: cannot create poolableconnectionfactory (could not create connection to database server

正负数值的正则表达式

final关键字和枚举类型

2022 safety officer-b certificate examination simulated 100 questions and answers
![376. Swing sequence [greedy, dynamic planning -----]](/img/c3/46cdd8c9320c529171cbf963c768a7.png)
376. Swing sequence [greedy, dynamic planning -----]

【高数】高数平面立体几何

Title and answer of work permit for safety management personnel of hazardous chemical business units in 2022
随机推荐
3D全景展示新模式,成为破局的关键
QT基础练手小程序-简单计算器设计(附带源码,解析)
Problems encountered in upgrading golang to version 1.18.4
【AUTOSAR-RTE】-3-Runnable及其Task Mapping映射
Activiti startup error: cannot create poolableconnectionfactory (could not create connection to database server
[附下载]推荐几款暴力破解和字典生成的工具
JDBC connection database
final关键字和枚举类型
蓝牙技术|2025年北京充电桩总规模达70万个,聊聊蓝牙与充电桩的不解之缘
[one flower, one world - Professor Zheng Yi - the way of simplicity] interpretable neural network
IntelliJ idea associated database
[gossip] the development of programmers needs two abilities most
信息学奥赛一本通 1617:转圈游戏 | 1875:【13NOIP提高组】转圈游戏 | 洛谷 P1965 [NOIP2013 提高组] 转圈游戏
express搭建一个简易的本地后台(一)
QT basic hand training applet - simple calculator design (with source code, analysis)
Changes in the relationship between data and application in IT industry
[Download] several tools for brute force cracking and dictionary generation are recommended
canvas常用原型方法及绘制图片应用
【英语考研词汇训练营】Day 15 —— analyst,general,avoid,surveillance,compared
IT行业数据与应用关系的变迁