cs文件:
- usingSystem;
@H_502_12@usingSystem.Collections.Generic;- usingSystem.ComponentModel;
@H_502_12@usingSystem.Data;- usingSystem.Drawing;
@H_502_12@usingSystem.Linq;- usingSystem.Text;
@H_502_12@usingSystem.Windows.Forms;- usingSystem.Data.sqlite;
@H_502_12@- usingDevComponents.DotNetBar;
@H_502_12@- namespaceMyWinForm
@H_502_12@{- publicpartialclassForm1:Office2007Form
@H_502_12@{- publicForm1()
@H_502_12@{- InitializeComponent();
@H_502_12@}- @H_502_12@privatevoidForm1_Load(objectsender,EventArgse)
- {
@H_502_12@sqliteConnectiondbConnection=newsqliteConnection("DataSource=../../test.db;");- sqliteCommanddbCommand=newsqliteCommand("SELECT*FROMuser",dbConnection);
@H_502_12@dbCommand.CommandType=CommandType.Text;- sqliteDataAdapterdbDataAdapter=newsqliteDataAdapter(dbCommand);
@H_502_12@DataSetdataSet=newDataSet();- dbDataAdapter.Fill(dataSet,"user");
@H_502_12@dataGridView1.DataSource=dataSet.Tables["user"];- }
@H_502_12@- }
@H_502_12@}
设计器生成:
- namespaceMyWinForm
@H_502_12@{- partialclassForm1
@H_502_12@{- ///<summary>
@H_502_12@///必需的设计器变量。- ///</summary>
@H_502_12@privateSystem.ComponentModel.IContainercomponents=null;- @H_502_12@///<summary>
- ///清理所有正在使用的资源。
@H_502_12@///</summary>- ///<paramname="disposing">如果应释放托管资源,为true;否则为false。</param>
@H_502_12@protectedoverridevoidDispose(booldisposing)- {
@H_502_12@if(disposing&&(components!=null))- {
@H_502_12@components.Dispose();- }
@H_502_12@base.Dispose(disposing);- }
@H_502_12@- #regionWindows窗体设计器生成的代码
@H_502_12@- ///<summary>
@H_502_12@///设计器支持所需的方法-不要- ///使用代码编辑器修改此方法的内容。
@H_502_12@///</summary>- privatevoidInitializeComponent()
@H_502_12@{- this.components=newSystem.ComponentModel.Container();
@H_502_12@System.ComponentModel.ComponentResourceManagerresources=newSystem.ComponentModel.ComponentResourceManager(typeof(Form1));- this.bindingSource1=newSystem.Windows.Forms.BindingSource(this.components);
@H_502_12@this.dataGridView1=newSystem.Windows.Forms.DataGridView();- this.id=newSystem.Windows.Forms.DataGridViewTextBoxColumn();
@H_502_12@this.uname=newSystem.Windows.Forms.DataGridViewTextBoxColumn();- this.password=newSystem.Windows.Forms.DataGridViewTextBoxColumn();
@H_502_12@((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit();- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
@H_502_12@this.SuspendLayout();- //
@H_502_12@//dataGridView1- //
@H_502_12@this.dataGridView1.AllowUserToAddRows=false;- this.dataGridView1.AllowUserToDeleteRows=false;
@H_502_12@this.dataGridView1.BackgroundColor=System.Drawing.Color.White;- this.dataGridView1.ColumnHeadersHeightSizeMode=System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
@H_502_12@this.dataGridView1.Columns.AddRange(newSystem.Windows.Forms.DataGridViewColumn[]{- this.id,
@H_502_12@this.uname,- this.password});
@H_502_12@this.dataGridView1.Dock=System.Windows.Forms.DockStyle.Fill;- this.dataGridView1.Location=newSystem.Drawing.Point(0,0);
@H_502_12@this.dataGridView1.Name="dataGridView1";- this.dataGridView1.ReadOnly=true;
@H_502_12@this.dataGridView1.RowTemplate.Height=23;- this.dataGridView1.Size=newSystem.Drawing.Size(344,191);
@H_502_12@this.dataGridView1.TabIndex=0;- //
@H_502_12@//id- //
@H_502_12@this.id.DataPropertyName="uid";- this.id.HeaderText="用户标识";
@H_502_12@this.id.Name="id";- this.id.ReadOnly=true;
@H_502_12@//- //uname
@H_502_12@//- this.uname.DataPropertyName="uname";
@H_502_12@this.uname.HeaderText="用户名";- this.uname.Name="uname";
@H_502_12@this.uname.ReadOnly=true;- //
@H_502_12@//password- //
@H_502_12@this.password.DataPropertyName="password";- this.password.HeaderText="密码";
@H_502_12@this.password.Name="password";- this.password.ReadOnly=true;
@H_502_12@//- //Form1
@H_502_12@//- this.AutoScaleDimensions=newSystem.Drawing.SizeF(6F,12F);
@H_502_12@this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;- this.BottomLeftCornerSize=15;
@H_502_12@this.BottomRightCornerSize=15;- this.ClientSize=newSystem.Drawing.Size(344,191);
@H_502_12@this.Controls.Add(this.dataGridView1);- this.Icon=((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
@H_502_12@this.Name="Form1";- this.Text="用户资料";
@H_502_12@this.Load+=newSystem.EventHandler(this.Form1_Load);- ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit();
@H_502_12@((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();- this.ResumeLayout(false);
@H_502_12@- }
@H_502_12@- #endregion
@H_502_12@- privateSystem.Windows.Forms.BindingSourcebindingSource1;
@H_502_12@privateSystem.Windows.Forms.DataGridViewdataGridView1;- privateSystem.Windows.Forms.DataGridViewTextBoxColumnid;
@H_502_12@privateSystem.Windows.Forms.DataGridViewTextBoxColumnuname;- privateSystem.Windows.Forms.DataGridViewTextBoxColumnpassword;
@H_502_12@- }
@H_502_12@}
运行界面:
注意需要引用System.Data.sqlite.dll
原文链接:https://www.f2er.com/sqlite/202811.html