DevExpress.XtraGrid 的使用方法 自动填充数据

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);
                  
                }
 
            }
        }

 

转载于:https://www.cnblogs.com/it1688/archive/2010/07/13/1776882.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值