HTML viewing and editing component for WinForms apps
Heres some sample code that allows you to incorporate HTML viewing and editing into your own Windows Forms app.
http://www.nikhilk.net/HTMLEdITingComponent.ASPx
功能毕竟简单,代码却是不少

A Windows Forms based text editor with HTML output
By kevin delafield

A Windows Forms based text editor with HTML output, implemented with a browser control in edit mode.
http://www.codeproject.com/KB/edit/editor_in_windows_forms.aspx
这个不错

An extended RichTextBox to save and load "HTML lite" files
By Oscar Londono

This control provides a method to save and load HTML files directly, avoiding the use of RTF codes.
似乎对汉字不是特别兼容

WinForms C#:html编辑器工程源码,含直接写WebBrowser的文件流、IPersistStreamInit接口的声明和一些相关的小方法
这个好像不是很··

HTML viewing and edITing component for WinForms apps

http://www.nikhilk.NET/HTMLEdITingComponent.ASPx

http://www.codeproject.com/cs/miscctrl/edITor_in_windows_forms.ASP
http://www.codeproject.com/cs/miscctrl/HTMLrichtextbox.ASP

 ~
 Sqlite数据库里指定数据类型为:Blob。

在数据访问指定参数类型为:DbType.Binary

然后把Excel文件读到字节数组里。

        using(FileStream file = File.Open(this.TextBox2.Text,FileMode.Open))
        &leftsign;       
            byte[] bytes = new byte[file.Length];
            file.Read(bytes, 0, Convert.ToInt32(file.Length));
            testDal.Insert(Guid.NewGuid().ToString(), bytes, null);
        &rightsign;

数据访问存储字节数据。
public Int32 Insert(string ID,Byte[] fileStream, SQLiteTransaction trans)
        &leftsign;
            if (conn.State == ConnectionState.Closed)
            &leftsign;
                conn.Open();
            &rightsign;
            SQLiteCommand command;
            if (trans == null)
            &leftsign;
                command = new SQLiteCommand("insert into test(ID,excelText) values (:ID,:excelText)", conn);
            &rightsign;
            else
            &leftsign;
                command = new SQLiteCommand("insert into test(ID,excelText) values (:ID,:excelText)", conn, trans);
            &rightsign;
            command.Parameters.Add("ID", DbType.String);
            command.Parameters.Add("excelText", DbType.Binary);

            command.Parameters["ID"].Value = ID;
            command.Parameters["excelText"].Value = fileStream;
            try
            &leftsign;
                return command.ExecuteNonQuery();
            &rightsign;
            catch
            &leftsign;
                return 0;
            &rightsign;
        &rightsign;

根据主键返回Excel的字节数据
        public byte[] GetExcel(string ID)
        &leftsign;
            if (conn.State == ConnectionState.Closed)
            &leftsign;
                conn.Open();
            &rightsign;
            SQLiteCommand command = new SQLiteCommand("Select excelText from test where ID = :ID", conn);
            command.Parameters.Add("ID", DbType.String);
            command.Parameters["ID"].Value = ID;

            SQLiteDataReader dr = null;

            dr = command.ExecuteReader();

            byte[] File = null;
            if (dr.Read())
            &leftsign;
                File = (byte[])dr[0];
            &rightsign;
            return File;
        &rightsign;

把字节数据存储为文件
        using (FileStream fs = File.Create("D:\\\\Test.xls"))
        &leftsign;
            fs.Write(file, 0, file.Length);
            fs.Close();
        &rightsign;
 ~
   A。
  该方法主要是利用了 SQLiteParameter 的功能,读取blob字段。代码如下:

    FileStream m_filestream = null;
  
            try &leftsign;
           
                m_filestream = new FileStream(@"d:\\pcinfo\\17.jpg", FileMode.Open, FileAccess.Read);          //读取图片

                SQLiteCommand m_commd2=new SQLiteCommand();
                m_commd2.CommandText="UPDATE test1 set timage=@idimage WHERE tparendid=78";
                            
               
                Byte[] m_byte = new Byte[m_filestream.Length]; //存放图片

                m_filestream.Read(m_byte,0,m_byte.Length);

                m_filestream.Close();

                SQLiteParameter param_m=new SQLiteParameter("@idimage",DbType.Binary,m_byte.Length,                    ParameterDirection.Input,false,0,0,null,DataRowVersion.Current,m_byte);
                m_commd2.Parameters.Add(param_m);                m_commd2.Parameters.Add(param_m);      //很多参数阿,注意DBType.Binary
  
                m_commd2.Connection = m_conn;
                m_commd2.ExecuteNonQuery();

          &rightsign;
            catch (SQLiteException ex)
            &leftsign;

                MessageBox.Show("未能存入图片");
  
            &rightsign;
     ~
     在C#中,在datagridview列表中可能会出现日期格式不对的错误。

发现若在SQLite中的日期格式字段如果写成 2008-8-21 在填充到datagridview中就会报错,说日期格式不对。但如果把2008-8-21 改成 2008-08-21 就OK了,晕,2008-8-21 和2008-08-21 有区别么。。。

没办法,只能在编辑页面的DateTimePicker 控件上做出改变

DateTimePicker tmpDtp = new DateTimePicker();
tmpDtp.CustomFormat = "yyyy-MM-dd";
tmpDtp.Format = DateTimePickerFormat.Custom;

历史博文

标签:, ,
八月 18, 2009 at 12:00 上午 by yippee 1,048 次
Category: Info
Tags: , ,