如何将blob字段的内容放在richtextboxextended字段中 [英] How do I put contents of a blob field in a richtextboxextended field
问题描述
求助。
我在MYSQL中定义了一个名为RTFText的blob字段的表格。
显示是用richtextboxextended.dll执行的。
说明:
私有RichTextBoxExtended.RichTextBoxExtended richTextBoxExtended1;
this.richTextBoxExtended1 = new RichTextBoxExtended.RichTextBoxExtended();
//
// richTextBoxExtended1
//
this.richTextBoxExtended1.Anchor =((System.Windows.Forms.AnchorStyles)((((System.Windows .Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.richTextBoxExtended1.DetectURLs = true;
this.richTextBoxExtended1.DocumentName =& quot; document.rtf& quot ;;
this.richTextBoxExtended1.Location = new System.Drawing.Point(240,8);
this.richTextBoxExtended1.Name =& quot; richTextBoxExtended1& quot ;;
this.richTextBoxExtended1.PrintActions = RichTextBoxExtended.PrintActions.StandardPrint;
this.richTextBoxExtended1.ShowBold = true;
this.richTextBoxExtended1.ShowCenterJustify = true;
this.richTextBoxExtended1.ShowColors = true;
this.richTextBoxExtended1.ShowFont = true;
this.richTextBoxExtended1.ShowItalic = true;
this.richTextBoxExtended1.ShowLeftJustify = true;
this.richTextBoxExtended1.ShowOpen = false;
this.richTextBoxExtended1.ShowPrint = true;
this.richTextBoxExtended1.ShowRedo = true;
this.richTextBoxExtended1.ShowRightJustify = true;
this.richTextBoxExtended1.ShowSave = false;
this.richTextBoxExtended1.ShowStamp = false;
this.richTextBoxExtended1.ShowStrikeout = false;
this.richTextBoxExtended1.ShowUnderline = true;
this.richTextBoxExtended1.ShowUndo = true;
this.richTextBoxExtended1.Size = new System.Drawing.Size(720,480);
this.richTextBoxExtended1.StampAction = RichTextBoxExtended.StampActions.EditedBy;
this.richTextBoxExtended1.StampColor = System.Drawing.Color.Blue;
this.richTextBoxExtended1.TabIndex = 21
private System.Windows.Forms.RichTextBox ergebnis;
ergebnis = richTextBoxExtended1.RichTextBox;
ergebnis.WordWrap = true;
ergebnis.AcceptsTab = true;
ergebnis.ShowSelectionMargin = true;
ergebnis.KeyUp + = new KeyEventHandler(ergebnis_KeyUp);
richTextBoxExtended1.Toolbar.Buttons [richTextBoxExtended1.Toolbar.Buttons.Add()]。Style = ToolBarButtonStyle.Separator;
tbGetPic = richTextBoxExtended1.Toolbar.Buttons [richTextBoxExtended1.Toolbar.Buttons.Add()];
tbGetPic.ToolTipText =VorhandeneBilderkönnenausgewähltwerden;
try
{
tbGetPic.ImageIndex = richTextBoxExtended1.Toolbar.ImageList.Images.AddStrip(imageList.Images [3]);
}
catch {}
tbGetDrw = richTextBoxExtended1.Toolbar.Buttons [richTextBoxExtended1.Toolbar.Buttons.Add()];
tbGetDrw.ToolTipText =VorhandeneZeichnungenkönnenausgewähltwerden;
try
{
tbGetDrw.ImageIndex = richTextBoxExtended1.Toolbar.ImageList.Images.AddStrip(imageList.Images [4]);
}
catch {}
tbPrint = richTextBoxExtended1.Toolbar.Buttons [20];
richTextBoxExtended1.Toolbar.ButtonClick + = new ToolBarButtonClickEventHandler(toolBar_ButtonClick);
可以将ergebnis.Rtf写入blob字段RTFText,但我发现没有从RTFText获取数据的方法ergebnis.Rtf
ergebnis.Rtf = row [RTFText]。ToString()导致崩溃。尝试... catch没有带来任何提示(只有无效的文件格式 - 但没有使用文件!
任何解决方案?
在此先感谢mikr41
我怀疑你在某处需要这样的东西。你有一个字节,你需要将它转换回来使用fileStream和二进制编写器可以帮助你做到这一点。
// 创建一个文件来保存输出。
fs = new FileStream( logo + pub_id + 。bmp,FileMode.OpenOrCreate,FileAccess.Write);
bw = new BinaryWriter(fs);
Hi please help.
I have defined in MYSQL a table with a blob field named RTFText.
The display is performed with richtextboxextended.dll.
Definitions:
private RichTextBoxExtended.RichTextBoxExtended richTextBoxExtended1; this.richTextBoxExtended1 = new RichTextBoxExtended.RichTextBoxExtended(); // // richTextBoxExtended1 // this.richTextBoxExtended1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.richTextBoxExtended1.DetectURLs = true; this.richTextBoxExtended1.DocumentName = "document.rtf"; this.richTextBoxExtended1.Location = new System.Drawing.Point(240, 8); this.richTextBoxExtended1.Name = "richTextBoxExtended1"; this.richTextBoxExtended1.PrintActions = RichTextBoxExtended.PrintActions.StandardPrint; this.richTextBoxExtended1.ShowBold = true; this.richTextBoxExtended1.ShowCenterJustify = true; this.richTextBoxExtended1.ShowColors = true; this.richTextBoxExtended1.ShowFont = true; this.richTextBoxExtended1.ShowItalic = true; this.richTextBoxExtended1.ShowLeftJustify = true; this.richTextBoxExtended1.ShowOpen = false; this.richTextBoxExtended1.ShowPrint = true; this.richTextBoxExtended1.ShowRedo = true; this.richTextBoxExtended1.ShowRightJustify = true; this.richTextBoxExtended1.ShowSave = false; this.richTextBoxExtended1.ShowStamp = false; this.richTextBoxExtended1.ShowStrikeout = false; this.richTextBoxExtended1.ShowUnderline = true; this.richTextBoxExtended1.ShowUndo = true; this.richTextBoxExtended1.Size = new System.Drawing.Size(720, 480); this.richTextBoxExtended1.StampAction = RichTextBoxExtended.StampActions.EditedBy; this.richTextBoxExtended1.StampColor = System.Drawing.Color.Blue; this.richTextBoxExtended1.TabIndex = 21 private System.Windows.Forms.RichTextBox ergebnis; ergebnis = richTextBoxExtended1.RichTextBox; ergebnis.WordWrap = true; ergebnis.AcceptsTab = true; ergebnis.ShowSelectionMargin = true; ergebnis.KeyUp += new KeyEventHandler(ergebnis_KeyUp); richTextBoxExtended1.Toolbar.Buttons[richTextBoxExtended1.Toolbar.Buttons.Add("")].Style = ToolBarButtonStyle.Separator; tbGetPic = richTextBoxExtended1.Toolbar.Buttons[richTextBoxExtended1.Toolbar.Buttons.Add("")]; tbGetPic.ToolTipText = "Vorhandene Bilder können ausgewählt werden"; try { tbGetPic.ImageIndex = richTextBoxExtended1.Toolbar.ImageList.Images.AddStrip(imageList.Images[3]); } catch { } tbGetDrw = richTextBoxExtended1.Toolbar.Buttons[richTextBoxExtended1.Toolbar.Buttons.Add("")]; tbGetDrw.ToolTipText = "Vorhandene Zeichnungen können ausgewählt werden"; try { tbGetDrw.ImageIndex = richTextBoxExtended1.Toolbar.ImageList.Images.AddStrip(imageList.Images[4]); } catch { } tbPrint = richTextBoxExtended1.Toolbar.Buttons[20]; richTextBoxExtended1.Toolbar.ButtonClick += new ToolBarButtonClickEventHandler(toolBar_ButtonClick);
It is possible to write ergebnis.Rtf to the blob field RTFText, but I found no way to get Data from RTFText into ergebnis.Rtf
ergebnis.Rtf = row["RTFText"].ToString() causes a crash. try...catch has not brought any hint (only "invalid file format" - but there is no file used!
Any solutions?
Thanks in advance mikr41
I suspect you'll need something like this in there somewhere. You have a blob of bytes, you need to convert it back and using a fileStream and a binary writer can help you do that.
// Create a file to hold the output. fs = new FileStream("logo" + pub_id + ".bmp", FileMode.OpenOrCreate, FileAccess.Write); bw = new BinaryWriter(fs);
这篇关于如何将blob字段的内容放在richtextboxextended字段中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!