vsflexgrid控件显示数据的问题,我晕了........

goldenLoveYou 2005-08-01 12:10:20
刚刚开始用vsflexgrid,7.0版本(PoJie),手头只有一个网上下载的控件浏览对照表,很多地方讲解不全。
环境:SQL+VB6.0
要求:将SQL表中的数据显示在vsflexgrid中
程序部分:
dim rst as adodb.recordset
'连接部分就不写了,这部分没问题
set vsflexgrid.datasource=rst
vsflexrid.text=rst.filed(0) & ""


.text属性这里是用的Mshflexgrid中的,主要是实在找不到该用什么属性了...
这里不知道该用什么属性,就是不能把数据填入控件显示....是用哪个属性啊?mshflexgrid里面的.text在vsflexgrid中就没用,它只填入了1个单元格,而不是整张vsflexgrid 控件表。
麻烦给各位指点一下,如果可以,希望能加个QQ类的及时通方法,便于请教,谢谢
...全文
409 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
goldenLoveYou 2005-08-02
  • 打赏
  • 举报
回复
哭了~~控件选择有问题,不应该选LIGHT的...........
goldenLoveYou 2005-08-02
  • 打赏
  • 举报
回复
下面是我给VSFLEXGRID网格写入数据的部分代码,其中有自定义的函数1个
'*——ExecuteSQL()是1个挂接SQL数据库的函数,没任何问题。 MSFDATA是VSFLEXGRID控件名称。 DBRST是另一个ADODB.Recordset,其作用是向控件中写入的SQL表数据。SELTAB是一个选择打开表的名称。
Dim CountL As Integer
Dim CountC As Integer
Dim CCL As Integer
'Dim CCK As Integer
Dim Crst As ADODB.Recordset
Set Crst = ExecuteSQL("select count(*) from syscolumns where id=object_id('" & SelTab & "')") '*——此处是获取SQL表的列数目
CCL = Crst.Fields(0)
Set Crst = Nothing
Crst.Close
MsgBox CCL
'CCK = DBRst.RecordCount - 1
MsgBox CCK
For CountC = 0 To DBRst.recordCount-1
For CountL = 0 To CCL
'MsfData.Select CountC + 1, CountL + 1
MsfData.TextMatrix(CountC + 1, CountL + 1) = DBRst.Fields(CountL) & ""
Next CountL
DBRst.MoveNext
Next CountC

————————————————————————————————————————
程序中一些数据的结果 DBRST.Record-1=19 ,也就是说总共有19列
问题是VSFLEXGRID控件只显示了9列,行数是对的共43行,也就是说其他10列的数据没有。
有点乱,不知道看清楚没有。
TrueYi 2005-08-01
  • 打赏
  • 举报
回复
一般采用的是
.TextMatrix(i, j) =rst.filed(0) & ""
TrueYi 2005-08-01
  • 打赏
  • 举报
回复
我提供的资料,可以看一下,较为全面的vsflexgrid
http://club.5ivb.net/dispbbs.asp?boardID=126&Page=1&ID=39602
goldenLoveYou 2005-08-01
  • 打赏
  • 举报
回复
通讯方法留在短信里面吧~~谢谢了~
fishmans 2005-08-01
  • 打赏
  • 举报
回复
你是怎么给网格赋值的?
绑定记录集还是写网格?

给代码看看
goldenLoveYou 2005-08-01
  • 打赏
  • 举报
回复
谢谢各位的回答!
VSFLEXGRID控件挂接数据这么麻烦啊?!

TO:fishmans(金脚指)及各位
我测试了,问题出现了,怎么过不了第十列?!,数据本来有19列,但是到了第10列就中止了,只显示了9列,后面的没有显示......,这是控件问题嘛??还是POJIE的就这样??
fishmans 2005-08-01
  • 打赏
  • 举报
回复
.text是当前单元格内容
.TextMatrix(i, j) =rst.filed(0) & "",I为行J为列
xyhv 2005-08-01
  • 打赏
  • 举报
回复
Set vsflexgrid.DataSource = rst.Clone
NI和vsFlexGrid控件.part3,共三部分!! VB代码: VSFlexGrid1.ExplorerBar = flexExSortShow Dim i As Long With VSFlexGrid1 .Cell(flexcpChecked, 1, 0, 3, 0) = flexUnchecked .Cell(flexcpAlignment, 0, 0, .Rows - 1, .Cols - 1) = flexAlignCenterCenter .Cols = 5 .Rows = 4 For i = 1 To 4 .TextMatrix(0, i) = "学生档案 " .ColAlignment(i) = 4 Next .TextMatrix(1, 0) = "序号 " .TextMatrix(2, 0) = "2 " .TextMatrix(3, 0) = "2 " .TextMatrix(1, 1) = "姓名 " .TextMatrix(1, 2) = "姓名 " .TextMatrix(1, 3) = "性别 " .TextMatrix(1, 4) = "年龄 " .MergeCells = flexMergeRestrictRows .MergeRow(0) = True .MergeRow(1) = True .MergeCol(0) = True For i = 1 To .Rows - 1 .Cell(flexcpBackColor, i, 1, i, 4) = RGB(i * 100, i * 100, i * 100) Next End With VC代码: m_vsgshow.SetCols(5); m_vsgshow.SetRows(4); for (int i=0;i<5;i++) { m_vsgshow.SetTextMatrix(0,i,"学生档案"); m_vsgshow.SetColAlignment(i,4); } m_vsgshow.SetTextMatrix(1,0,"序号"); m_vsgshow.SetTextMatrix(2,0,"2"); m_vsgshow.SetTextMatrix(3,0,"2"); m_vsgshow.SetTextMatrix(1,1,"姓名"); m_vsgshow.SetTextMatrix(1,2,"姓名"); m_vsgshow.SetTextMatrix(1,3,"性别"); m_vsgshow.SetTextMatrix(1,4,"年龄"); m_vsgshow.SetMergeCells(2); m_vsgshow.SetMergeRow(0,true); m_vsgshow.SetMergeRow(1,true); m_vsgshow.SetMergeCol(0,true); // m_vsgshow.SetCellChecked(1); for (i=1;ivsgshow.GetRows();i++) { m_vsgshow.SetRow(i); m_vsgshow.SetCellChecked(2); // m_vsgshow.setcell // m_vsgshow.SetBackColor(RGB(10*i,10*i,10*i)); // m_vsgshow.SetCellBackColor(); } VC使用CCWGraph: COleSafeArray m_saRet; long index[3]; static long m_lData; //m_lData++; //m_wave.SetYDataAppend(COleVariant(sin(3.1415*m_lData/100))); DWORD numElements[]={3,1}; m_saRet.Create(VT_R8,2,numElements); //创建一个安全数组 index[1]=0; index[2]=1; m_lData++; for(index[0]=0;index[0]<3;index[0]++) { double val=index[0]*5+4.5*sin(3.1415*m_lData/100); m_saRet.PutElement(index,&val
NI和vsFlexGrid控件.part2,共三部分!! VB代码: VSFlexGrid1.ExplorerBar = flexExSortShow Dim i As Long With VSFlexGrid1 .Cell(flexcpChecked, 1, 0, 3, 0) = flexUnchecked .Cell(flexcpAlignment, 0, 0, .Rows - 1, .Cols - 1) = flexAlignCenterCenter .Cols = 5 .Rows = 4 For i = 1 To 4 .TextMatrix(0, i) = "学生档案 " .ColAlignment(i) = 4 Next .TextMatrix(1, 0) = "序号 " .TextMatrix(2, 0) = "2 " .TextMatrix(3, 0) = "2 " .TextMatrix(1, 1) = "姓名 " .TextMatrix(1, 2) = "姓名 " .TextMatrix(1, 3) = "性别 " .TextMatrix(1, 4) = "年龄 " .MergeCells = flexMergeRestrictRows .MergeRow(0) = True .MergeRow(1) = True .MergeCol(0) = True For i = 1 To .Rows - 1 .Cell(flexcpBackColor, i, 1, i, 4) = RGB(i * 100, i * 100, i * 100) Next End With VC代码: m_vsgshow.SetCols(5); m_vsgshow.SetRows(4); for (int i=0;i<5;i++) { m_vsgshow.SetTextMatrix(0,i,"学生档案"); m_vsgshow.SetColAlignment(i,4); } m_vsgshow.SetTextMatrix(1,0,"序号"); m_vsgshow.SetTextMatrix(2,0,"2"); m_vsgshow.SetTextMatrix(3,0,"2"); m_vsgshow.SetTextMatrix(1,1,"姓名"); m_vsgshow.SetTextMatrix(1,2,"姓名"); m_vsgshow.SetTextMatrix(1,3,"性别"); m_vsgshow.SetTextMatrix(1,4,"年龄"); m_vsgshow.SetMergeCells(2); m_vsgshow.SetMergeRow(0,true); m_vsgshow.SetMergeRow(1,true); m_vsgshow.SetMergeCol(0,true); // m_vsgshow.SetCellChecked(1); for (i=1;ivsgshow.GetRows();i++) { m_vsgshow.SetRow(i); m_vsgshow.SetCellChecked(2); // m_vsgshow.setcell // m_vsgshow.SetBackColor(RGB(10*i,10*i,10*i)); // m_vsgshow.SetCellBackColor(); } VC使用CCWGraph: COleSafeArray m_saRet; long index[3]; static long m_lData; //m_lData++; //m_wave.SetYDataAppend(COleVariant(sin(3.1415*m_lData/100))); DWORD numElements[]={3,1}; m_saRet.Create(VT_R8,2,numElements); //创建一个安全数组 index[1]=0; index[2]=1; m_lData++; for(index[0]=0;index[0]<3;index[0]++) { double val=index[0]*5+4.5*sin(3.1415*m_lData/100); m_saRet.PutElement(index,&val

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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