找回密码
 立即注册

QQ登录

只需一步,快速开始

DCAgile

中级会员

83

主题

247

帖子

794

积分

中级会员

积分
794

活字格认证微信认证勋章元老葡萄

DCAgile
中级会员   /  发表于:2015-9-22 17:05  /   查看:9370  /  回复:11
使用如下代码实现图片添加:
        string FilePath1 = Application.StartupPath + "\\Image\\1.png";
        string FilePath2 = Application.StartupPath + "\\Image\\2.png";
        string FilePath3 = Application.StartupPath + "\\Image\\3.png";
        string FilePath4 = Application.StartupPath + "\\Image\\4.png";

private void AddImage()
        {
            System.Drawing.Image img = System.Drawing.Image.FromFile(FilePath1);
            System.Drawing.Image img2 = System.Drawing.Image.FromFile(FilePath2);
            System.Drawing.Image img3 = System.Drawing.Image.FromFile(FilePath3);
            System.Drawing.Image img4 = System.Drawing.Image.FromFile(FilePath4);

            List<System.Drawing.Image> list = new List<System.Drawing.Image>();
            list.Add(img);
            list.Add(img2);
            list.Add(img3);
            list.Add(img4);

            for (int i = 0; i < list.Count; i++)
            {
                System.Drawing.Image thumbImage = list.GetThumbnailImage(200, 200, null, System.IntPtr.Zero);
                TXTextControl.Image image = new TXTextControl.Image(thumbImage);
                textControl1.Images.Add(image, textControl1.InputPosition.TextPosition);
            }
        }

问题:1.如何为每张图片添加间隔??效果如下所示:
test.PNG

11 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2015-9-22 18:07:00
沙发
回复 1楼DCAgile的帖子

实现代码如下:

  1.             System.Drawing.Image img = System.Drawing.Image.FromFile(FilePath1);
  2.             System.Drawing.Image img2 = System.Drawing.Image.FromFile(FilePath2);
  3.             System.Drawing.Image img3 = System.Drawing.Image.FromFile(FilePath3);
  4.             System.Drawing.Image img4 = System.Drawing.Image.FromFile(FilePath4);

  5.             List<System.Drawing.Image> list = new List<System.Drawing.Image>();
  6.             list.Add(img);
  7.             list.Add(img2);
  8.             list.Add(img3);
  9.             list.Add(img4);

  10.             for (int i = 0; i < list.Count; i++)
  11.             {
  12.                 //System.Drawing.Image thumbImage = list.GetThumbnailImage(200, 200, null, System.IntPtr.Zero);
  13.                 TXTextControl.Image image = new TXTextControl.Image(list[i]);
  14.                 textControl1.Images.Add(image, textControl1.InputPosition.TextPosition);
  15.                 this.textControl1.Select(this.textControl1.Text.Length, 0);
  16.                 this.textControl1.Selection.Text = "    ";
  17.             }
复制代码


为了给你提供更优质的服务,请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢

评分

参与人数 1满意度 +5 收起 理由
DCAgile + 5 对以往的合作满意,希望后续的合作效率更高

查看全部评分

回复 使用道具 举报
DCAgile
中级会员   /  发表于:2015-9-24 09:59:00
板凳

如何控制Tx Control中一行(一个段落)中显示图片的个数以及对其方式

回复 2楼iceman的帖子

问题:

1.如何控制在Tx Control一行中加载图片的个数? (例如如下图中一行只能加载三张图片)  
      
2.如何控制加载图片后的对其方式?  (例如如下图中——居中对其)
test.PNG
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2015-9-24 11:19:00
地板
回复 3楼DCAgile的帖子

建议通过Table来布局,在单元格中插入图片。请您想尝试,有后续问题我们再讨论。
回复 使用道具 举报
DCAgile
中级会员   /  发表于:2015-9-25 11:22:00
5#
回复 4楼iceman的帖子

问题:
1.TX Control中添加Table——Id设置是否有什么限制(设置为1、2出错)?

2.如何设置Table的边框、对其方式、单元格高度(通过编码的方式)?
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2015-9-25 12:29:00
6#
回复 5楼DCAgile的帖子

TableID从 11开始设置,需要大于10。
Table边框可以通过以下代码隐藏:

  1.             this.textControl1.Tables.GridLines = false;
复制代码


对齐方式需要单元格逐个设置:

  1. private void setBorderToolStripMenuItem_Click(object sender, EventArgs e)
  2.         {
  3.             Table tb = this.textControl1.Tables.GetItem(12);
  4.             

  5.             foreach (TableCell cell in this.textControl1.Tables.GetItem(12).Cells)
  6.             {
  7.                 cell.CellFormat.VerticalAlignment = VerticalAlignment.Top;
  8.             }
  9.         }
复制代码


单元格左右对齐方式需要通过 ParagraphFormat.Alignment 属性来设置。
回复 使用道具 举报
DCAgile
中级会员   /  发表于:2015-9-25 14:14:00
7#
回复 6楼iceman的帖子

问题:
1.单元格左右对齐方式需要通过 ParagraphFormat.Alignment 属性来设置。
  和你电话沟通,说需通过Selection选中当前行,进行设置,还是不太清楚 怎么获取,,

  具体应该怎么操作??
回复 使用道具 举报
DCAgile
中级会员   /  发表于:2015-9-25 14:55:00
8#
回复 7楼DCAgile的帖子

不用回了 问题已解决
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2015-9-25 15:17:00
9#
回复 8楼DCAgile的帖子

设置Border测试代码如下:

  1.         private void Form1_Load(object sender, EventArgs e)
  2.         {
  3.             this.textControl1.Tables.Add(10, 10, 11);
  4.             this.textControl1.Selection.Text = &quot;\n\n\n\n&quot;;
  5.             this.textControl1.Tables.Add(10, 10, 12);
  6.             this.textControl1.Tables.GridLines = false;
  7.         }

  8.         private void setBorderToolStripMenuItem_Click(object sender, EventArgs e)
  9.         {
  10.             Table tb = this.textControl1.Tables.GetItem(11);
  11.             

  12.             foreach (TableCell cell in this.textControl1.Tables.GetItem(11).Cells)
  13.             {
  14.                 cell.CellFormat.TopBorderWidth = 20;
  15.                 cell.CellFormat.LeftBorderWidth= 20;
  16.                 cell.CellFormat.RightBorderWidth = 20;
  17.                 cell.CellFormat.BottomBorderWidth = 20;
  18.             }
  19.         }
复制代码
回复 使用道具 举报
DCAgile
中级会员   /  发表于:2015-9-25 16:14:00
10#
回复 9楼iceman的帖子

这种方式只适用于使用代码添加的表格,对于创建模版添加的表格无法操作
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部