炫彩界面库论坛

 找回密码
 加入我们

QQ登录

只需一步,快速开始

查看: 5688|回复: 8

如何给list表格中添加图片

[复制链接]

该用户从未签到

发表于 2017-5-22 13:30:59 | 显示全部楼层 |阅读模式
2炫彩币
如何给list表格中添加图片   就是表格内容可以实现图片和文字的混合显示   求指点   谢谢

最佳答案

查看完整内容

如果你还是用的你发的模板,那就是错的因为你的三列全都是图片元素, 如果你更换了正确的模板,而且第一列元素是ShapeText,那就看一下项模板是不是真的加载成功了.... 项目模板: 代码:

该用户从未签到

发表于 2017-5-22 13:31:00 | 显示全部楼层
如果你还是用的你发的模板,那就是错的因为你的三列全都是图片元素,

QQ截图20170522175755.png



如果你更换了正确的模板,而且第一列元素是ShapeText,那就看一下项模板是不是真的加载成功了....


QQ截图20170522182610.png

项目模板:
  1. <?xml version="1.0" encoding="gb2312" ?>
  2. <!--炫彩界面库-列表元素项模板文件-->
  3. <xc_template_list showT="true">
  4.     <listHeader_item showT="true">
  5.         <layoutObject heightT="30" layout.alignH="left" layout.alignV="center" layout.height="fill" layout.horizon="true" layout.padding="2,2,15,2" layout.space="5" layout.width="fill" showT="true" widthT="300">
  6.             <layoutObject layout.alignH="left" layout.alignV="center" layout.height="fill" layout.horizon="true" layout.padding="0,2,0,0" layout.width="14" showT="true" />
  7.             <shapeText content="歌曲名" layout.height="20" layout.width="auto" left="41" showT="true" top="25" width="20" />
  8.         </layoutObject>
  9.         <layoutObject heightT="30" layout.alignH="left" layout.alignV="center" layout.height="fill" layout.horizon="true" layout.padding="2,2,2,2" layout.space="2" layout.width="fill" showT="true" widthT="300">
  10.             <shapeText content="专辑" itemID="0" layout.height="fill" layout.width="auto" showT="true" />
  11.         </layoutObject>
  12.         <layoutObject heightT="30" layout.alignH="left" layout.alignV="center" layout.height="fill" layout.horizon="true" layout.padding="2,2,2,2" layout.space="2" layout.width="fill" showT="true" widthT="300">
  13.             <shapeText content="时长" itemID="0" layout.height="fill" layout.width="auto" showT="true" />
  14.         </layoutObject>
  15.     </listHeader_item>
  16.        
  17.     <list_Item showT="true">
  18.         <layoutObject heightT="30" layout.alignH="left" layout.alignV="center" layout.height="fill" layout.horizon="true" layout.padding="15,2,2,2" layout.space="5" layout.width="fill" showT="true" widthT="300">
  19.              <shapePicture height="100" image="{binding field=name source=data bSync=false}" layout.height="fill" layout.width="52" left="58" showT="true" top="38" width="100" />
  20.         </layoutObject>
  21.         <layoutObject heightT="30" layout.alignH="left" layout.alignV="center" layout.height="fill" layout.horizon="true" layout.padding="2,2,2,2" layout.space="2" layout.width="fill" showT="true" widthT="300">
  22.             <textLinkUI content="{binding field=name2}" drawBorder="false" drawFocus="false" height="20" itemID="105" layout.width="auto" left="177" showT="true" top="252" transparent="true" underlineLeave="true" underlineStay="true" width="100" />
  23.         </layoutObject>
  24.         <layoutObject heightT="30" layout.alignH="left" layout.alignV="center" layout.height="fill" layout.horizon="true" layout.padding="2,2,2,2" layout.space="2" layout.width="fill" showT="true" widthT="300">
  25.             <shapeText content="{binding field=name3}" layout.height="20" layout.width="auto" left="152" showT="true" top="324" />
  26.         </layoutObject>
  27.    
  28.     </list_Item>
  29. </xc_template_list>
复制代码



代码:
  1. m_hList = XList_Create(0,30,500,470,myForm.m_hWindow);
  2.         if(m_hList == 0)
  3.         {
  4.                 ::MessageBoxA(0,"","",0);
  5.         }
  6.         XEle_AddBkFill(m_hList,255,200);
  7.         XList_SetItemTemplateXML(m_hList,L"F:\\工程源码\\VC++\\TestDui\\Debug\\sgTreeListItemSelect.xml");
  8.         XList_SetItemHeightDefault(m_hList,30,50);
  9.     XList_AddColumn(m_hList,100);
  10.     XList_AddColumn(m_hList,100);
  11.         XList_AddColumn(m_hList,100);
  12.       
  13.         HXCGUI hAdapterHeader=XAdMap_Create();
  14.         XList_BindAdapterHeader(m_hList,hAdapterHeader);
  15.         XAdMap_AddItemText(hAdapterHeader,(XC_NAME),L"aaa");
  16.         XAdMap_AddItemText(hAdapterHeader,(XC_NAME2),L"bbb");
  17.         XAdMap_AddItemText(hAdapterHeader,(XC_NAME3),L"ccc");
  18.         
  19.         HXCGUI hAdapter=XAdTable_Create();
  20.         XList_BindAdapter(m_hList,hAdapter);
  21.         XAdTable_AddColumn(hAdapter,(XC_NAME));
  22.         XAdTable_AddColumn(hAdapter,(XC_NAME2));
  23.         XAdTable_AddColumn(hAdapter,(XC_NAME3));

  24.     XList_SetColumnWidth(m_hList,0,150);
  25.         XList_SetColumnWidth(m_hList,1,150);
  26.         XList_SetColumnWidth(m_hList,2,150);

  27.                 wchar_t tmp[MAX_PATH]={0};
  28.                 HIMAGE hImage = XImage_LoadFile(L"C:\\Users\\COST\\Desktop\\QQ截图20170522171656.png",TRUE);
  29.                 int nId = 0;
  30.         for (int i=0;i<20;i++)
  31.         {
  32.             wsprintf(tmp,L"item-%d",i);
  33.                         if(hImage == 0)
  34.                         {
  35.                                 ::MessageBoxA(0,"","",0);
  36.                         }
  37.                         //XAdTable_AddItemImage(hAdapter,hImage);

  38.                         nId = XAdTable_AddItemImage(hAdapter,hImage);

  39.             wsprintf(tmp,L"child-%d-1",i);  XAdTable_SetItemText(hAdapter,i,1,tmp);
  40.             wsprintf(tmp,L"child-%d-2",i);  XAdTable_SetItemText(hAdapter,i,2,tmp);
  41.         }
复制代码




回复

使用道具 举报

该用户从未签到

发表于 2017-5-22 16:11:43 | 显示全部楼层
使用自定义模板,设置绑定数据,
回复

使用道具 举报

该用户从未签到

 楼主| 发表于 2017-5-22 16:39:09 | 显示全部楼层
花舞灬花丶落泪 发表于 2017-5-22 16:11
使用自定义模板,设置绑定数据,
  1. <?xml version="1.0" encoding="gb2312" ?>
  2. <!--炫彩界面库-列表元素项模板文件-->
  3. <xc_template_list showT="true">
  4.     <listHeader_item showT="true">
  5.         <layoutObject layout.alignH="left" layout.alignV="center" layout.height="fill" layout.horizon="true" layout.padding="5,2,2,2" layout.space="6" layout.width="fill" showT="true">
  6.             <shapeText content="{binding field=name source=data bSync=false}" css.name="style_shapeText" itemID="1" layout.height="fill" layout.width="fill" showT="true" textAlign="DT_CENTER,DT_VCENTER,DT_SINGLELINE,DT_SHOW_VERTICAL" />
  7.         </layoutObject>
  8.         <layoutObject layout.alignH="left" layout.alignV="center" layout.height="fill" layout.horizon="true" layout.padding="5,2,2,2" layout.space="6" layout.width="fill" showT="true">
  9.             <shapeText content="{binding field=name2 source=data bSync=false}" css.name="style_shapeText" itemID="2" layout.height="fill" layout.width="fill" showT="true" />
  10.         </layoutObject>
  11.         <layoutObject layout.alignH="left" layout.alignV="center" layout.height="fill" layout.horizon="true" layout.padding="5,2,2,2" layout.space="6" layout.width="fill" showT="true">
  12.             <shapeText content="{binding field=name3 source=data bSync=false}" css.name="style_shapeText" itemID="3" layout.height="fill" layout.width="fill" showT="true" />
  13.         </layoutObject>
  14.     </listHeader_item>
  15.     <list_Item showT="true">
  16.         <layoutObject layout.alignH="left" layout.alignV="center" layout.height="fill" layout.horizon="true" layout.padding="2,2,2,2" layout.space="6" layout.width="fill" showT="true">
  17.             <shapePicture content="{binding field=name1 source=data bSync=false}" layout.height="fill" layout.width="fill" />
  18.         </layoutObject>
  19.         <layoutObject layout.alignH="left" layout.alignV="center" layout.height="fill" layout.horizon="true" layout.padding="2,2,2,2" layout.space="2" layout.width="fill" showT="true">
  20.             <shapePicture content="{binding field=name2 source=data bSync=false}" layout.height="auto" layout.width="auto" />
  21.         </layoutObject>
  22.         <layoutObject layout.alignH="left" layout.alignV="center" layout.height="fill" layout.horizon="true" layout.padding="2,2,2,2" layout.space="2" layout.width="fill" showT="true">
  23.             <shapePicture content="{binding field=name3 source=data bSync=false}" layout.height="auto" layout.width="auto" />
  24.         </layoutObject>
  25.     </list_Item>
  26. </xc_template_list>
复制代码


这是我那个布局模板文件   然后加载不了图啊
回复

使用道具 举报

该用户从未签到

发表于 2017-5-22 16:45:56 | 显示全部楼层
第一,保证图片存在,且能读,第二,保证添加数据的代码是  xAdtable_addItem*****
如果第一列是个ShapePic那就是
XAdTable_AddItemImage (hAdapter, hImage);
否则就是
XAdTable_AddItemText();

还有就是你的模板应该是没错的,你可以贴一张增加数据的代码,
回复

使用道具 举报

该用户从未签到

 楼主| 发表于 2017-5-22 17:06:56 | 显示全部楼层
花舞灬花丶落泪 发表于 2017-5-22 16:45
第一,保证图片存在,且能读,第二,保证添加数据的代码是  xAdtable_addItem*****
如果第一列是个ShapePic ...
  1. for (int i = 0; i < 20; i++)
  2.         {
  3.                 wsprintf(tmp, L"item-%d", i);
  4.                 XAdTable_AddItemText(hAdapter, tmp);
  5.                 wsprintf(tmp, L"child-%d-1", i);  
  6.                 XAdTable_SetItemText(hAdapter, i, 1, tmp);               
  7.                 XAdTable_AddItemImageEx(hAdapter, XC_NAME3, hImg);
  8.                 bRet = XAdTable_SetItemImageEx(hAdapter, i, XC_NAME3, hImg);
  9.         }
复制代码
我这样添加后   不显示图像啊    调试时图像句柄是加载成功的
回复

使用道具 举报

该用户从未签到

发表于 2017-5-22 17:09:19 | 显示全部楼层
大佬,问题出在你的代码上了, 你在模板中定义的第一列数据是ShapePic,而你在代码中却是写的XAdTable_AddItemText,当然不对了,  你需要把XAdTable_AddItemText 改成 XAdTable_AddItemImage
回复

使用道具 举报

该用户从未签到

发表于 2017-5-22 17:11:51 | 显示全部楼层
抱歉,我眼瞎了,之前没看仔细,你的模板列数据全都是ShapePic?  用什么显示文字啊? 你需要加上ShapeText或者其他的的可以显示字符串的元素啊。再或者你自己绘制。
回复

使用道具 举报

该用户从未签到

 楼主| 发表于 2017-5-22 17:39:45 | 显示全部楼层
花舞灬花丶落泪 发表于 2017-5-22 17:11
抱歉,我眼瞎了,之前没看仔细,你的模板列数据全都是ShapePic?  用什么显示文字啊? 你需要加上ShapeText或 ...

我第一列和第二列都是文本    其他列才是图像   然而 我测试后  还是不行啊   不能显示图像
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

QQ|Archiver|手机版|小黑屋|炫彩界面库 ( 鄂ICP备2023014763号-1 )

GMT+8, 2024-4-19 16:37 , Processed in 0.073642 second(s), 20 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表