我想在后台向文本框中加载一个图片,用了如下代码,但是老是抛异常,请问,我是不是哪儿写错了?
Size size = new Size(1, 1);//添加文本框
TXTextControl.TextFrame tf = new TextFrame(size);
tf.InsertionMode = TextFrameInsertionMode.AsCharacter;
tf.BorderWidth = 1;
tf.Name = "测试";
int[] margin = new int[4] { 0, 0 ,0, 0 };
tf.InternalMargins = margin;
this.textControl1.TextFrames.Add(tf,position);
string filepath = @"C:\Users\Administrator\Desktop\1.jpg";
System.Drawing.Image img = System.Drawing.Image.FromFile(filepath);
int textposition = tf.TextPosition;
TXTextControl.Image image = new TXTextControl.Image(img);
tf.Images.Add(image, TXTextControl.HorizontalAlignment.Left,textposition, ImageInsertionMode.AsCharacter);
int position = this.textControl1.InputPosition.TextPosition;
|
|