zoukankan      html  css  js  c++  java
  • DataGridView 为TextBox初始化,单击事件

    /*
    * 窗体描述:显示“长春市六条主要江河八五年洪水情况表”信息;
    * 功能: ;
    * 方法:GetRiverString();//根据传参“河流名称”“数据库连接串”进行查询
    * 作者: HeTao
    * 日期: 2011-03-12, 星期六
    * 版本:V1.0
    *
    * 修改人员:
    * 修改日期:
    * 修改内容:
    */
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Text;
    using System.Windows.Forms;
    using System.Data.SqlClient;

    namespace YNRBSYS.RiversInfoQuery
    {
    public partial class uc_6JL85HS : UserControl
    {

    /// <summary>
    ///
    /// </summary>
    /// <param name="RiverName">河流名称</param>
    /// <param name="connString">数据库连接串</param>

    public void GetRiverString(string RiverName, string connString)
    {
    try
    {
    SqlConnection conn
    = new SqlConnection(connString);

    conn.Open();

    string SqlStr = "SELECT * from CC_RIVER_HSXX "+
    "WHERE (RIVERCODE ='" + RiverName + "')";

    DataSet ds
    = new DataSet();

    SqlDataAdapter sda
    = new SqlDataAdapter();

    sda.SelectCommand
    = new SqlCommand(SqlStr, conn);

    sda.Fill(ds,
    "info");

    SqlCommand scmd
    = new SqlCommand(SqlStr, conn);

    SqlDataReader objSqlReader
    = scmd.ExecuteReader();

    while (objSqlReader.Read())
    {

    dataGridViewX1.DataSource
    = ds.Tables[0];

    }

    }
    catch (Exception ex)
    {

    MessageBox.Show(ex.Message);

    }

    }

    private void setDataGridViewString()
    {
    if (dataGridViewX1.SelectedRows.Count > 0)
    {
    int i = dataGridViewX1.SelectedRows[0].Index;

    txtHSNF.Text
    = dataGridViewX1.Rows[i].Cells[1].Value.ToString();

    txtHLMC.Text
    = dataGridViewX1.Rows[i].Cells[2].Value.ToString();

    txtXQ.Text
    = dataGridViewX1.Rows[i].Cells[4].Value.ToString();

    txtZDSW.Text
    = dataGridViewX1.Rows[i].Cells[5].Value.ToString();

    txtZM.Text
    = dataGridViewX1.Rows[i].Cells[3].Value.ToString();

    txtZDLL.Text
    = dataGridViewX1.Rows[i].Cells[6].Value.ToString();

    txtFSSJ.Text
    = dataGridViewX1.Rows[i].Cells[7].Value.ToString();

    txtDWZYQKXZ.Text
    = dataGridViewX1.Rows[i].Cells[8].Value.ToString();

    txtDWZYQKZRT.Text
    = dataGridViewX1.Rows[i].Cells[9].Value.ToString();

    txtDWZYQKHS.Text
    = dataGridViewX1.Rows[i].Cells[10].Value.ToString();

    txtDWZYQKRK.Text
    = dataGridViewX1.Rows[i].Cells[11].Value.ToString();

    txtDWZYQKFW.Text
    = dataGridViewX1.Rows[i].Cells[12].Value.ToString();

    txtDWZYQKGD.Text
    = dataGridViewX1.Rows[i].Cells[13].Value.ToString();

    txtBZ.Text
    = dataGridViewX1.Rows[i].Cells[14].Value.ToString();
    }
    }
    public uc_6JL85HS()
    {

    InitializeComponent();

    }
    //dataGridView 为textbox初始化值
    private void uc_6JL85HS_Load(object sender, EventArgs e)
    {

    setDataGridViewString();

    }

    private void dataGridViewX1_CellClick(object sender, DataGridViewCellEventArgs e)
    {

    setDataGridViewString();

    }
    }
    }
  • 相关阅读:
    【数位dp】Beautiful Numbers @2018acm上海大都会赛J
    【状压dp】Trie 树 @中山纪念中学20170304
    两个给点染色的问题-树上染色与图上染色
    【贪心】经营与开发 @upc_exam_5500
    【二分+拓扑排序】Milking Order @USACO 2018 US Open Contest, Gold/upc_exam_6348
    【并查集】Connectivity @ABC049&amp;ARC065/upcexam6492
    【倍增】T-shirt @2018acm徐州邀请赛 I
    Sparse Coding: Autoencoder Interpretation
    Sparse Coding
    Pooling
  • 原文地址:https://www.cnblogs.com/beeone/p/2000031.html
Copyright © 2011-2022 走看看