RicherTextBox 편집양식 그대로 저장하기 위한 예제 입니다. 이미지도 같이 저장되게요...
RicherTextBox 의 RTF 구조를 데이터 베이스에 byte 형태로 저장해서 불러온다.
일단 http://www.codeproject.com/Articles/24443/RicherTextBox 가서
RicherTextBox 편집기 하나를 받았다.
여기에 RTF 저장 및 불러 오기만 구현했음

*데이터베이스 저장은 MDF (MS -SQL) 와 엔티티6으로 저장하였습니다.
목록조회
private void button2_Click(object sender, EventArgs e)
{ Database1Entities entities = new Database1Entities(); list = entities.TestTable.ToList(); this.dataGridView1.DataSource = list; }
등록화면
붙여넣기도 됨
저장하기 소스
private void RicherTextBox1_dbSaveClick_click(object sender, string Rtf) { Database1Entities entities = new Database1Entities(); TestTable tt = new TestTable(); RichTextBox rt = sender as RichTextBox; tt.Contents = rt.Text; ASCIIEncoding encoding = new ASCIIEncoding(); byte[] array = encoding.GetBytes(Rtf); tt.ObjectContents = array; tt.CreateDate = DateTime.Now; entities.TestTable.Add(tt); entities.SaveChanges(); MessageBox.Show("등록완료"); this.DialogResult = DialogResult.OK; this.Close(); }
불러오기
더블클릭해서 불러온상태
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { TestTable tt = list[e.RowIndex] as TestTable; Form2 mf = new Form2(tt); if (mf.ShowDialog() == DialogResult.OK) { button2.PerformClick(); } }private void Form2_Load(object sender, EventArgs e) { richerTextBox1.dbSaveClick_click += RicherTextBox1_dbSaveClick_click; if (this.tt != null) { byte[] contentBytes = tt.ObjectContents; richerTextBox1.SetByteText(contentBytes); } }
'C#.NET' 카테고리의 다른 글
Visual Studio 용 Visual C++ 재배포 가능 패키지 다운로드 (0) | 2023.04.11 |
---|---|
C# (Attribute) Obsolete 사용안하는 메소드 표시 (0) | 2019.08.21 |
Json.NET c#에서 Json 파싱하기 (0) | 2019.07.18 |
RTF 포멧을 HTML 포멧으로 변경하기 (0) | 2016.08.23 |
IIS 32비트 허용 (0) | 2013.08.22 |
Enum 데이터바인딩 및 가져오기 (0) | 2013.05.14 |
GroupBox Control Extensions (0) | 2013.05.06 |
[ Assembly ,어셈블리 ] 클래스 이름으로 동적으로 컨트롤 생성하기 (1) | 2013.03.08 |
개체의 선입선출(FIFO) / LIFO(후입선출) (0) | 2012.06.27 |
[ GMap.NET ] c# 에서 구글맵,빙맵등을 을 빠르고 간편하게 개발 (1) | 2012.03.13 |