c# datagridview 绑定mysql_C#中DataGridView绑定数据库怎么操作?

本文介绍了在C#中使用DataGridView绑定MySQL数据库的步骤,包括创建数据表结构,设置DataGrid控件的数据源,并展示了如何在DataGrid的某一列使用ComboBox进行数据选择。此外,还提供了焦点模拟和数据提交的实现方法。
摘要由CSDN通过智能技术生成

33cacde18302f3c76304fc54a78f9e4d.png

DataGrid有三中绑定数据的方法,二楼介绍了一种,我就再介绍一种吧,dataGridView1.SetDataBinding(DataSet."表名");插入删除的话,放一个例题上去吧

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

namespace DataGridTest

{

public class frmForm:System.Windows.Forms.Form

{

private System.Windows.Forms.DataGrid dbgNewGrid;

private DataTable tbSourceTable;

private System.Windows.Forms.Button cmdFocus;

private System.ComponentModel.Container components = null;

public frmForm()

{

InitializeComponent();

PopulateGrid();

}

protected override void Dispose( bool disposing )

{

if ( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows 窗体设计器生成的代码

private void InitializeComponent()

{

this.dbgNewGrid = new System.Windows.Forms.DataGrid();

this.cmdFocus = new System.Windows.Forms.Button();

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值