关于MSHFlexGrid代码填充时出现的隐藏行问题,麻烦各位高手帮忙解答,谢谢!!

JAVAMARS 2007-06-02 06:08:01
我现在做的程序通过“录入”按钮将两个变量(sID ,sPart)添加到MSHFlexGrid中,方法是:
Grid_Selected.Row = 1
Grid_Selected.Col = 1
Grid_Selected.text=sID
Grid_Selected.Row = 1
Grid_Selected.Col = 2
Grid_Selected.text=sPart
或者是:
Grid_Selected.AddItem (sID & vbTab & sPart)
“删除”按钮将选中的行删除:
Grid_Selected.RemoveItem (Grid_Selected.Row)
这些功能都实现了,具体方法就不写了。但是出现了一个问题,就是如果我添加了几行之后,再删除几行,然后再添加,这个时候添加的行不显示,是隐藏的,但是确实存在这些数据在MSHFlexGrid中。好像是删除了几行,然后再添加的时候就有几个隐藏的行。在删除和添加后我都Refresh过了,但是还是出现这种情况,请问这种情况怎么解决?
谢谢大家!!
...全文
369 点赞 收藏 13
写回复
13 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
whsug 2007-06-22
重新设置行高
回复
guyehanxinlei 2007-06-16
建议使用MSFlexgrid控件
回复
MicLee521 2007-06-16
换成MSFlexgrid控件,就没有这个问题了。
回复
JAVAMARS 2007-06-04
去掉了,问题依旧
回复
of123 2007-06-04
去掉 Grid_Selected.Rows = Rowss - 1,让 Rows 属性自动增减。
回复
JAVAMARS 2007-06-04
additem的方法我也试验过了,跟我写的这个功能一样,没有问题,但是再删除几行后,再进行添加操作才会出现隐藏的行,好像是删除了几行再添加就出现几个不显示的行。
这是删除的方法:
Dim II As Long '---删除时的行号
Private Sub CMD_DEL_Click()
Dim Rowss As Long
Rowss = Grid_Selected.Rows
If Grid_Selected.Rows <= 2 Then
Grid_Selected.Row = 1
Grid_Selected.Col = 2
Grid_Selected.Text = ""
Grid_Selected.Col = 3
Grid_Selected.Text = ""
Else
If II >= 1 Then
Grid_Selected.RemoveItem (II)
II = 0 ' 初始化删除行
Grid_Selected.Rows = Rowss - 1
Else
MsgboxTS ("请选择一条纪录!")
End If
Grid_Selected.Refresh
End If
Grid_Selected.SetFocus
Grid_CHKpart.SetFocus
End Sub

Private Sub Grid_Selected_RowColChange() '-----删除第几行
II = Grid_Selected.Row
End Sub
回复
JAVAMARS 2007-06-04
还有没有人能帮忙啊??
回复
clear_zero 2007-06-02
我做了个例子
你说 插入数据(从最大行插入)-------,那个不就是最后一行么
我用的是
Grid.additem

也没refresh, 都是显示的

你换成.additem试试看
回复
JAVAMARS 2007-06-02
我贴一下代码吧,这个是添加的,是从另一个MSHFlexGrid中提取的数据
Private Sub CMD_Choise_Click()
Dim i As Integer
Dim InsROW, cROWS, sROWS As Long
Dim cHID, sID, sPart As String

sROWS = Grid_CHKpart.Rows
cROWS = Grid_Selected.Rows
Grid_CHKpart.Col = 2
sID = Trim(Grid_CHKpart.Text)
Grid_CHKpart.Col = 3
sPart = Trim(Grid_CHKpart.Text)

'------判断是否有重复纪录-------
i = 1
While i <= cROWS
Grid_Selected.Row = i - 1
Grid_Selected.Col = 2
If Grid_Selected.Text = sID Then
MsgboxTS ("该部位已选择!请重新选择部位!")
GoTo ENDSUB
End If
i = i + 1
Wend
'--------------END---------------

'------判断最大行-------
If cROWS <= 2 Then
Grid_Selected.Row = 1
Grid_Selected.Col = 2
cHID = Trim(Grid_Selected.Text)
If cHID = "" Then
InsROW = 1
Else
InsROW = 2
Grid_Selected.Rows = cROWS + 1
End If
Else
InsROW = cROWS
End If
'--------END--------


'------插入数据(从最大行插入)-------
If cROWS > 2 Then
Grid_Selected.Rows = cROWS + 1
End If
Grid_Selected.SetFocus
Grid_Selected.Row = InsROW
Grid_Selected.Col = 2
Grid_Selected.Text = sID
Grid_Selected.Col = 3
Grid_Selected.Text = sPart
Grid_Selected.TopRow = Grid_Selected.Rows - 1
Grid_Selected.Refresh
Grid_CHKpart.SetFocus
'------END------------------
ENDSUB: End Sub
回复
JAVAMARS 2007-06-02
滚动条本来就是全开的
回复
JAVAMARS 2007-06-02
还是不行啊,每次执行Grid_Selected.TopRow = Grid_Selected.Rows - 1这句话的时候Grid_Selected.TopRow 的值一直是1啊
回复
clear_zero 2007-06-02
你把两个滚动条都打开,看看解决问题么?
回复
饮水需思源 2007-06-02
可能是增加的行超过了控件的显示范围,这样试试:
mshflexgrid1.row=msfhlexgrid1.rows-1
mshflexgrid1.toprow=mshflexgrid1.row
回复
相关推荐
发帖
控件
创建于2007-09-28

1426

社区成员

VB 控件
申请成为版主
帖子事件
创建了帖子
2007-06-02 06:08
社区公告
暂无公告