DELPHI里很容易解决,VB里就这么难吗?在VSFlexGrid表格里画线问题(DrawCell里写代码)。
能画出这样的效果我给300分。
http://www.cwsoft.net/money1.jpg
能画出这样的效果我给500分。
http://www.cwsoft.net/money2.jpg最好给代码例子,能把它搞成自定义控件就最好了。MailTo:[email protected]以下是参考的例子。是也是画的例子。VS自代的。Private Sub fa_DrawCell(ByVal hDC As Long, ByVal Row As Long, ByVal col As Long, ByVal left As Long, ByVal top As Long, ByVal right As Long, ByVal bottom As Long, done As Boolean)
Dim clr&, clrg&, l&
Dim rc As RECT
Dim rc1 As RECT
Dim clr1$, clr2$
Dim r1%, g1%, b1%
Dim r2%, g2%, b2%
Dim rg%, gg%, bg%
With fa
' make sure we need to draw this guy
clr1 = .TextMatrix(Row, 0)
clr2 = .TextMatrix(Row, 1)
If Row > 0 And col = 2 And clr1 <> "" And clr2 <> "" Then
' get rectangle
rc.left = left
rc.top = top
rc.right = right
rc.bottom = bottom
' draw frame
clr = SetBkColor(hDC, 0)
ExtTextOut hDC, rc.left, rc.top, ETO_OPAQUE, rc, " ", 1, l
InflateRect rc, -1, -1
' get colors
GetRGB clr1, r1, g1, b1
GetRGB clr2, r2, g2, b2
' show color
rc1 = rc
For l = rc.left To rc.right Step 3
rg = r1 + (l - rc.left) * (r2 - r1) / (rc.right - rc.left)
gg = g1 + (l - rc.left) * (g2 - g1) / (rc.right - rc.left)
bg = b1 + (l - rc.left) * (b2 - b1) / (rc.right - rc.left)
clrg = RGB(rg, gg, bg)
SetBkColor hDC, clrg
rc1.left = l
ExtTextOut hDC, rc1.left, rc1.top, ETO_OPAQUE, rc1, " ", 1, l
Next
' done, restore hDC and quit
SetBkColor hDC, clr
done = True
End If
End With
End Sub
能画出这样的效果我给300分。
http://www.cwsoft.net/money1.jpg
能画出这样的效果我给500分。
http://www.cwsoft.net/money2.jpg最好给代码例子,能把它搞成自定义控件就最好了。MailTo:[email protected]以下是参考的例子。是也是画的例子。VS自代的。Private Sub fa_DrawCell(ByVal hDC As Long, ByVal Row As Long, ByVal col As Long, ByVal left As Long, ByVal top As Long, ByVal right As Long, ByVal bottom As Long, done As Boolean)
Dim clr&, clrg&, l&
Dim rc As RECT
Dim rc1 As RECT
Dim clr1$, clr2$
Dim r1%, g1%, b1%
Dim r2%, g2%, b2%
Dim rg%, gg%, bg%
With fa
' make sure we need to draw this guy
clr1 = .TextMatrix(Row, 0)
clr2 = .TextMatrix(Row, 1)
If Row > 0 And col = 2 And clr1 <> "" And clr2 <> "" Then
' get rectangle
rc.left = left
rc.top = top
rc.right = right
rc.bottom = bottom
' draw frame
clr = SetBkColor(hDC, 0)
ExtTextOut hDC, rc.left, rc.top, ETO_OPAQUE, rc, " ", 1, l
InflateRect rc, -1, -1
' get colors
GetRGB clr1, r1, g1, b1
GetRGB clr2, r2, g2, b2
' show color
rc1 = rc
For l = rc.left To rc.right Step 3
rg = r1 + (l - rc.left) * (r2 - r1) / (rc.right - rc.left)
gg = g1 + (l - rc.left) * (g2 - g1) / (rc.right - rc.left)
bg = b1 + (l - rc.left) * (b2 - b1) / (rc.right - rc.left)
clrg = RGB(rg, gg, bg)
SetBkColor hDC, clrg
rc1.left = l
ExtTextOut hDC, rc1.left, rc1.top, ETO_OPAQUE, rc1, " ", 1, l
Next
' done, restore hDC and quit
SetBkColor hDC, clr
done = True
End If
End With
End Sub
解决方案 »
- (求教高手)我在ActiveReports报表中放DataGrid,在运得时为什么会出现死机??
- 在VB中调用存储过程
- 如何检测到光驱按钮按下时产生的事件
- Edit2
- 使用 CreateFile 打开串口问题?
- 〓〓〓请问如果代码中动态创建控件数组,这个控件数组数量上有没有上限?〓〓〓
- 关于treeview控件
- 关于vb+oracle开发的问题,为什么我一运行我的应用程序,系统就写一个set.log文件,吧我的机器搞得很慢!为什么阿。事什么原因
- VB连接数据库在其他没有装VB的操作系统上为何就用不了?
- 怎样可以使窗体的长度大于屏幕最大长度(滚动条会自动加上去吗)?
- 求救
- 还是菜鸟问题 拼图游戏的一段代码
至于画线嘛,你可以先用SELECT方法选定一个范围,再设置边框的大小及颜色即可
能帮我写一个简单的例子吗?我对VB不熟。我是一直用delphi的。成功了500分全给你。
后面的哪个图的标题可以看做是2行和12列的合并,具体代码我不写了,重复工作而已
我给你关键的代码部分:
With MSHFlexGrid1
.FixedRows = 2 //标题行数
.MergeCells = flexMergeFree //自由合并
.row = 0
.MergeRow(0) = True //合并第一行
.ColAlignmentFixed = flexAlignCenterCenter
.TextMatrix(0, n) = text
.TextMatrix(0, n+1) = text
........................
.TextMatrix(0, n+11) = text //完成上半部分12列的合并
//然后对其他单元格进行2行的合并
.TextMatrix(0, col) = text1
.TextMatrix(1, col) = text1
.MergeCol(col) = True
End With那条红线我不知道怎样画,等别的高手指点吧