请教关于控件数组

ylz2008 2006-01-16 01:44:43
有一程序,用到了50个EDIT控件
然后从某数据文件中读出50个数据依次用这50个EDIT控件显示.

请教可以显示的循环语句.
wsprintf( gString, "%d", gValue );
SetDlgItemText(IDC_EDIT1,(LPCSTR)gString);
如何将这里面的IDC_EDIT以一个数组代替,感谢.搜索了CSDN,大多以VB\DELPHI解决,请教VC的办法
...全文
120 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ylz2008 2006-01-16
  • 打赏
  • 举报
回复
我的resource.h中如下定义
但是用你的方法
for(int i=0; i<50; i++)
{
wsprintf( gString, "%d", gValue );
SetDlgItemText(IDC_EDIT1+i,(LPCSTR)gString);
}
后,EDIT2后的显示都正常,EDIT1不显示,请指教


#define IDC_EDIT1 1011
#define IDC_EDIT2 1012
#define IDC_EDIT3 1013
#define IDC_EDIT4 1014
#define IDC_EDIT5 1015
#define IDC_EDIT6 1016
#define IDC_EDIT7 1017
#define IDC_EDIT8 1018
#define IDC_EDIT9 1019
#define IDC_EDIT10 1020
#define IDC_EDIT11 1021
#define IDC_EDIT12 1022
#define IDC_EDIT13 1023
#define IDC_EDIT14 1024
#define IDC_EDIT15 1025
#define IDC_EDIT16 1026
#define IDC_EDIT17 1027
#define IDC_EDIT18 1028
#define IDC_EDIT19 1029
#define IDC_EDIT20 1030
#define IDC_EDIT21 1031
#define IDC_EDIT22 1032
#define IDC_EDIT23 1033
#define IDC_EDIT24 1034
#define IDC_EDIT25 1035
#define IDC_EDIT26 1036
#define IDC_EDIT27 1037
#define IDC_EDIT28 1038
#define IDC_EDIT29 1039
#define IDC_EDIT30 1040
#define IDC_EDIT31 1041
#define IDC_EDIT32 1042
#define IDC_EDIT33 1043
#define IDC_EDIT34 1044
#define IDC_EDIT35 1045
#define IDC_EDIT36 1046
#define IDC_EDIT37 1047
#define IDC_EDIT38 1048
#define IDC_EDIT39 1049
#define IDC_EDIT40 1050
#define IDC_EDIT41 1051
#define IDC_EDIT42 1052
#define IDC_EDIT43 1053
#define IDC_EDIT44 1054
#define IDC_EDIT45 1055
#define IDC_EDIT46 1056
#define IDC_EDIT47 1057
#define IDC_EDIT48 1058
#define IDC_EDIT49 1059
#define IDC_EDIT50 1060
yingpf 2006-01-16
  • 打赏
  • 举报
回复
id 要连续
lixiaosan 2006-01-16
  • 打赏
  • 举报
回复
int gValue[50];

取出数据对gValue赋值
...

for(int i=0; i<50; i++)
{
wsprintf( gString, "%d", gValue[i] );
SetDlgItemText(IDC_EDIT1+i,(LPCSTR)gString);
}

lixiaosan 2006-01-16
  • 打赏
  • 举报
回复
首先。确保在resource.h中这50个edit的id是连续的

for(int i=0; i<50; i++)
{
wsprintf( gString, "%d", gValue );
SetDlgItemText(IDC_EDIT1+i,(LPCSTR)gString);
}

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧