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());
}
控件中国网提供DevExpress相关产品,请点击DevExpress下载,DevExpress产品价格。