C#空间

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

void repositoryItemTextEdit2_Leave(object sender, System.EventArgs e)
        {
            DataTable table1 = new DataTable();
            System.Data.SqlClient.SqlConnection sqlcon = new System.Data.SqlClient.SqlConnection();
            sqlcon.ConnectionString = "Data Source=192.168.1.1;Initial Catalog=Northwind;Persist Security Info=True;User ID=sa;Password=22";

            string ss = gridView1.GetRowCellDisplayText(gridView1.FocusedRowHandle, gridView1.Columns[0]);

            string selectCommand = "select * from Orders where OrderID in (" + ss + ")";
            System.Data.SqlClient.SqlDataAdapter dataAdapter = new System.Data.SqlClient.SqlDataAdapter(selectCommand, sqlcon);
            sqlcon.Open();
            dataAdapter.Fill(table1);
            sqlcon.Close();
            gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[1], table1.Rows[0]["ShipAddress"].ToString());
            gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns[2], table1.Rows[0]["ShipCity"].ToString());
        }

 

 private void repositoryItemTextEdit3_Leave(object sender, System.EventArgs e)
        {
            //throw new System.NotImplementedException();
            gridView1.FocusedRowHandle += 1;
            gridView1.FocusedColumn = gridView1.VisibleColumns[0];
            gridView1.ShowEditor();
        }

 

 private void repositoryItemTextEdit3_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            //throw new System.NotImplementedException();
            if (e.KeyCode == Keys.Enter)
            {
                if (dataSet1.Tables["Orders"].Rows.Count == gridView1.FocusedRowHandle + 1)
                {
                    DataRow dr = dataSet1.Tables["Orders"].NewRow();
                    dataSet1.Tables["Orders"].Rows.Add(dr);
                  
                }
 
            }
        }

 

posted on 2010-07-13 23:58  小海洋  阅读(942)  评论(0编辑  收藏  举报