数据库表:
CREATE TABLE [TABLE1] ( [id] [int] IDENTITY (1, 1) NOT NULL , [img] [image] NULL , [name] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO
程序代码:
黑体字部分为主要代码
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data;
namespace WindowsApplication1 { /// <summary> /// Form1 的摘要说明。 /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Data.SqlClient.SqlCommand sqlCommand1; private System.Data.SqlClient.SqlConnection sqlConnection1; private System.Windows.Forms.ListBox listBox1; private System.Windows.Forms.Splitter splitter1; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button1; private System.Windows.Forms.ContextMenu contextMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.SaveFileDialog saveFileDialog1; private System.Windows.Forms.Panel panel2; private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.MenuItem menuItem3; /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null;
public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent();
// // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // }
/// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); }
#region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.sqlCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlConnection1 = new System.Data.SqlClient.SqlConnection(); this.listBox1 = new System.Windows.Forms.ListBox(); this.splitter1 = new System.Windows.Forms.Splitter(); this.panel1 = new System.Windows.Forms.Panel(); this.button2 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); this.contextMenu1 = new System.Windows.Forms.ContextMenu(); this.menuItem1 = new System.Windows.Forms.MenuItem(); this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); this.panel2 = new System.Windows.Forms.Panel(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.menuItem3 = new System.Windows.Forms.MenuItem(); this.panel1.SuspendLayout(); this.panel2.SuspendLayout(); this.SuspendLayout(); // // listBox1 // this.listBox1.Dock = System.Windows.Forms.DockStyle.Left; this.listBox1.ItemHeight = 12; this.listBox1.Location = new System.Drawing.Point(0, 0); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(176, 412); this.listBox1.TabIndex = 4; // // splitter1 // this.splitter1.Location = new System.Drawing.Point(176, 0); this.splitter1.Name = "splitter1"; this.splitter1.Size = new System.Drawing.Size(3, 421); this.splitter1.TabIndex = 5; this.splitter1.TabStop = false; // // panel1 // this.panel1.Controls.Add(this.button2); this.panel1.Controls.Add(this.button1); this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; this.panel1.Location = new System.Drawing.Point(179, 349); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(469, 72); this.panel1.TabIndex = 6; // // button2 // this.button2.Location = new System.Drawing.Point(152, 16); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(208, 40); this.button2.TabIndex = 4; this.button2.Text = "选择图片存入数据库"; this.button2.Click += new System.EventHandler(this.button2_Click_1); // // button1 // this.button1.Location = new System.Drawing.Point(216, 16); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(88, 32); this.button1.TabIndex = 5; this.button1.Text = "读取"; this.button1.Visible = false; // // contextMenu1 // this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem1, this.menuItem2, this.menuItem3}); // // menuItem1 // this.menuItem1.Index = 0; this.menuItem1.Text = "另存"; //this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click); // // panel2 // this.panel2.AutoScroll = true; this.panel2.Controls.Add(this.pictureBox1); this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; this.panel2.Location = new System.Drawing.Point(179, 0); this.panel2.Name = "panel2"; this.panel2.Size = new System.Drawing.Size(469, 349); this.panel2.TabIndex = 7; // // pictureBox1
[1] [2] [3] 下一页 [系统软件]InstallShield Express for delphi制作安装程序定… [系统软件](转帖) 忘记登录密码的解决方案 for XP/2003/2000 [系统软件]交叉编译sshd for IXP425 ARM Platform by MVL 3… [Delphi程序]《关于VisiBroker For Delphi的使用》(4) [Delphi程序]一个超链接Image控件!(For D3,D4,D5,D6)源代码 [Delphi程序]Five of the best tools for Delphi [Delphi程序]《关于VisiBroker For Delphi的使用》(3) [Delphi程序]《关于VisiBroker For Delphi的使用》(2) [Delphi程序]《关于VisiBroker For Delphi的使用》 [Delphi程序]Delphi for .Net 编译器预览 - by John Kaster
|