DevExpress_常用控件10_GridLookUpEdit

本文介绍了DevExpress的GridLookUpEdit控件使用,包括如何在设计视图中添加列,设置列的Caption和FieldName,以及提供了相关的代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

2.2 GridLookUpEdit

2.1.2

demo1效果如下:


demo1步骤如下:

1. 拖一个GridLookupEdit放到窗口中

2. 点击右侧小箭头,弹出菜单,并选择Design View

3. AddColumns添加三列(ID,Age,Name)

4. 分别设置显示的Caption和字段来源FieldName

5. 写代码如下


demo1代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data.SqlClient;

namespace DXApplication_1
{
	public partial class GridLookupEditForm : DevExpress.XtraEditors.XtraForm
	{
		public GridLookupEditForm()
		{
			InitializeComponent();
		}

		public SqlConnection getConnection()
		{
			//连接本地数据库 server=localhost
			string connStr = @"server=.;database=db5;Integrated Security=true;";
			SqlConnection conn = new SqlConnection(connStr);
			return conn;
		}

		DataTable tmpTable = new DataTable();
		public DataTable getDataTable(string sqlStr)
		{
			SqlConnection sqlConn = this.getConnection();
			SqlDataAdapter adapter = new SqlDataAdapter(sqlStr, sqlConn);
			adapter.Fill(tmpTable);
			sqlConn.Close();
			sqlConn
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值