zoukankan      html  css  js  c++  java
  • DataGridView

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using APPcarDA;
    using APPcarfangfa;
    
    namespace WindowsFormsApplication2
    {
        public partial class Form3 : Form
        {
            public Form3()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                List<DA> list = new fangfa().select();
                dataGridView1.AutoGenerateColumns = false;//自动生成列
                dataGridView1.DataSource = list;//自动添加
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                MessageBox.Show( dataGridView1.SelectedCells[0].Value.ToString());//获取选中的单元格。选中的单元格的集合,最后选中的单元格在最前面
                dataGridView1.SelectedRows[0].Cells[0].Value.ToString();//选中的行集合,可以根据选中的行具体到这一行的任一单元格
                DA car=(DA) dataGridView1.SelectedRows[0].DataBoundItem;//将某一行直接转换成对象
                MessageBox.Show(car.Oil.ToString());
            }
        }
    }
  • 相关阅读:
    nginx负载均衡集群
    pureftp 服务
    LVS集群之DR模式 实现
    LVS集群之NAT模式实现
    resin 安装配置
    nfs部署和优化
    电压和电流有什么关系
    自动循环播放 播放器
    有趣的匿名方法
    使用匿名委托,Lambda简化多线程代码
  • 原文地址:https://www.cnblogs.com/dlexia/p/4618402.html
Copyright © 2011-2022 走看看