datagrid 中我如何行在 rowheader 上加上文字.....

LiloZhu 2004-06-23 07:38:19

cloumns header
______________________________________________
|
|
row header | cell 區
|
|
|
如何實一在row header 上加上文字,可以貼一個簡的例子.....
...全文
291 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
allanli 2004-07-04
  • 打赏
  • 举报
回复
呵呵,我只是给出一个大概的思路,分析一下代码应该不难发现他的原理的.
还是自己自立更新吧(因为我的DataGrid还有其他功能,代码中的一些变量是其他功能用到的,你可以用一些常量代替或者直接删除看看效果就可以了)
LiloZhu 2004-07-03
  • 打赏
  • 举报
回复
兄弟,有錯,可否抽空整理一下,發一個完整的帖子上來,供大家參考...兄北們感激不盡...
allanli 2004-07-02
  • 打赏
  • 举报
回复
'在DataGrid的OnPaint方法里面调用下面过程,可能不能编译通过(因为在我的代码中抽出来的,难免有遗漏)

Private Sub DrawRowHeader(ByVal dg As DataGrid, ByVal g As Graphics)
If Me.DesignMode Then Exit Sub
Try
Dim RowCount As Integer

If dg.DataSource Is Nothing Then
RowCount = -1
Else
RowCount = dg.BindingContext(dg.DataSource, dg.DataMember).Count
End If

If RowCount > 0 Then
Dim i As Integer
Dim j As Integer
Dim intCount As Integer = 0
Dim intTop As Integer
Dim intFirstRow As Integer
Dim intFirstRowTop As Integer
Dim NumberWidth As Integer

Dim blnRedFont As Boolean
Dim blnNoTableStyle As Boolean
Dim intColunmCount As Integer
Dim intItemIndex As Integer
Dim Rect As Rectangle
Dim sb As New SolidBrush(dg.BackColor)
Dim drs() As DataRow
Dim dv As DataView

Dim dgcs As DataGridColumnStyle
Dim strFieldCode As String
Dim strTemp As String
Dim strFormat As New StringFormat

If TypeOf Me.DataSource Is DataTable Then
dv = CType(Me.DataSource, DataTable).DefaultView
ElseIf TypeOf Me.DataSource Is DataView Then
dv = CType(Me.DataSource, DataView)
End If

NumberWidth = CInt(g.MeasureString(RowCount.ToString, dg.Font).Width) + 15
blnNoTableStyle = (dg.TableStyles.Count = 0)

If blnNoTableStyle Then
dg.RowHeaderWidth = NumberWidth
ElseIf NumberWidth > dg.TableStyles(0).RowHeaderWidth Then
dg.TableStyles(0).RowHeaderWidth = NumberWidth
End If

intFirstRowTop = dg.GetCellBounds(0, 0).Top
'''计算第一可视行,从第一可视行开始画起
intFirstRow = CInt(intFirstRowTop / ((dg.GetCellBounds(RowCount - 1, 0).Top - intFirstRowTop + dg.GetCellBounds(0, 0).Height) / RowCount))
'''减去Caption行和行头行
intFirstRow = intFirstRow - CInt(IIf(protCustomColumnsHeaders, protNRowsInCaption, IIf(dg.CaptionVisible = True, 2, 1)))
If intFirstRow < 0 Then
intFirstRow = -intFirstRow
Else
intFirstRow = 0
End If

For i = intFirstRow To RowCount - 1
intTop = dg.GetCellBounds(i, 0).Top + 2
g.DrawString(CStr(i + 1), dg.Font, New SolidBrush(Color.Black), 15, intTop)
next
end sub
LiloZhu 2004-07-02
  • 打赏
  • 举报
回复
可否帖出一个例子来给兄弟们看看,分不够,我可以再加....如何...
allanli 2004-07-01
  • 打赏
  • 举报
回复
继承DataGrid,重栽Paint方法自己画,外边大吧例子啦.
webmasterss 2004-06-30
  • 打赏
  • 举报
回复
我找了很久都没解决,只有在相应数据库表中多添加一个字段,使用时先根据一定规则UPDATE成想要的文字或数字,然后绑定作为行标题了,郁闷。。。
来个高手开发个自定义的控件吧!!
真相重于对错 2004-06-30
  • 打赏
  • 举报
回复
sorry
winform没用过
webform到是可以想想办法

LiloZhu 2004-06-30
  • 打赏
  • 举报
回复
WinFrom 中.....
LiloZhu 2004-06-30
  • 打赏
  • 举报
回复
繼續,希望能等到會使用的朋友出現....!!!
水如烟 2004-06-30
  • 打赏
  • 举报
回复
我查过这方面的资料,到目前止还没得到一点眉头
真相重于对错 2004-06-30
  • 打赏
  • 举报
回复
winform or webform
LiloZhu 2004-06-30
  • 打赏
  • 举报
回复
沒有人回答,難道真的沒有會做嗎,等待詳解...
水如烟 2004-06-30
  • 打赏
  • 举报
回复
对这个问题,我是抱着绝望的态度
本来我对什么事都很乐观的
企业通用软件 2004-06-30
  • 打赏
  • 举报
回复
我也要用到,关注中
LiloZhu 2004-06-23
  • 打赏
  • 举报
回复
如何 mark
bizbuy 2004-06-23
  • 打赏
  • 举报
回复
mark

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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