DevExpress的简单应用
- 开发笔记
- 2024/1/29 16:45:59
- 人已阅读
简介
using DevExpress.XtraGrid.Views.Grid; using DevExpress.XtraGrid.Views.Grid.DefaultSizing; using DevExpress.XtraGrid.Columns; using System.Windows.Forms; public partial class Form1 : Form { public Form1() { InitializeComponent(); // 创建数据源 DataTable dataTable = new DataTable(); dataTable.Columns.Add("ID", typeof(int)); dataTable.Columns.Add("Name", typeof(string)); dataTable.Columns.Add("Age", typeof(int)); dataTable.Rows.Add(1, "John Doe", 30); dataTable.Rows.Add(2, "Jane Smith", 25); dataTable.Rows.Add(3, "Bob Johnson", 40); // 创建GridView控件并绑定数据源 GridView view = new GridView(this); view.Name = "GridView1"; view.KeyFieldName = "ID"; view.Parent = this; view.DataSource = dataTable; view.BestFitColumns(); view.ShowHeader = true; view.Appearance.Fonts.AddRange(new Font[] { new Font("Arial", 8F) }); view.Appearance.Options.UseFonts = true; view.OptionsView.ShowGroupPanel = false; view.OptionsView.ShowFilterPanel = true; view.OptionsView.ShowFooter = true; view.OptionsView.ShowGroupPanel = false; view.GroupPanelText = ""; view.SortIndicator = true; view.OptionsBehavior.Editable = true; view.DefaultFocusedRowHandle = 0; view.FocusedColumn = view.Columns["ID"]; view.BestFit(); } }
下一篇:BinGe个人博客
文章评论
- 消灭零回复