Comments (7)
1、带CheckBox的TTreeView(lcl不支持的话仅vcl)
2、TListView
(1)Item和SubItem自绘控件:如图片、CheckBox(lcl不支持的话仅vcl)
(2)单元格上色:指定行、指定Item、指定SubItem
3、TStringGrid
(1)排序
(2)自绘控件(如图片、CheckBox)
(3)单元格上色
from govcl.
- 1、带CheckBox的TTreeView,只支持Windows,需要重新编译dev分支的libvcl源码。
- 2、TListView
- (1)、还未做,不过可以参考listviewcustomdraw
- (2)、可参考 listviewcustomdraw的自绘
- 3、TStringGrid
- (1) 排序未做
- (2) 自绘控件参考drawgrid
- (3) 不咋明白咋样的上色。
from govcl.
“单元格上色”指的就是给单元格加个背景色。TListView中我发现个比较怪的问题,在SetOnAdvancedCustomDrawItem事件中,只调用:
sender.Canvas().Brush().SetColor(colors.ClRed)
对第一个Item上色后,后面的SubItem都上成同样颜色了。如果只想对第一列的单元格上色,不知道有什么好的办法?当前我测试时发现可以在SetOnAdvancedCustomDrawSubItem事件中把SubItem的颜色再上回去,但感觉方法比较土。
from govcl.
@ismlsmile TListView的项目就是根据项目的列索引设置Brush的不同颜色
from govcl.
比如需求是这样的,只要设置第一列的颜色为红色,但下面的例子中,ListViewAdvancedCustomDrawItem设置后,整行都会变为红色
package main
import (
"fmt"
"github.com/ying32/govcl/vcl"
"github.com/ying32/govcl/vcl/types"
"github.com/ying32/govcl/vcl/types/colors"
"math/rand"
)
func main() {
vcl.Application.Initialize()
mainForm := vcl.Application.CreateForm()
mainForm.SetPosition(types.PoScreenCenter)
mainForm.SetWidth(500)
mainForm.SetHeight(400)
lv1 := vcl.NewListView(mainForm)
lv1.SetParent(mainForm)
lv1.SetAlign(types.AlTop)
lv1.SetRowSelect(true)
lv1.SetReadOnly(true)
lv1.SetViewStyle(types.VsReport)
lv1.SetGridLines(true)
col := lv1.Columns().Add()
col.SetCaption("序号")
col.SetWidth(100)
col = lv1.Columns().Add()
col.SetCaption("项目1")
col.SetWidth(200)
lv1.Items().BeginUpdate()
for i := 1; i <= 20; i++ {
item := lv1.Items().Add()
item.SetCaption(fmt.Sprintf("%d", i+rand.Int()))
item.SubItems().Add(fmt.Sprintf("值:%d", i+rand.Int()))
}
lv1.Items().EndUpdate()
lv1.SetOnAdvancedCustomDrawItem(ListViewAdvancedCustomDrawItem)
vcl.Application.Run()
}
func ListViewAdvancedCustomDrawItem(sender *vcl.TListView, item *vcl.TListItem, state types.TCustomDrawState, Stage types.TCustomDrawStage, defaultDraw *bool) {
sender.Canvas().Brush().SetColor(colors.ClRed)
}
from govcl.
@ismlsmile 大概这样子吧
package main
import (
"fmt"
"math/rand"
"github.com/ying32/govcl/vcl"
"github.com/ying32/govcl/vcl/types"
"github.com/ying32/govcl/vcl/types/colors"
)
func main() {
vcl.Application.Initialize()
mainForm := vcl.Application.CreateForm()
mainForm.SetPosition(types.PoScreenCenter)
mainForm.SetWidth(500)
mainForm.SetHeight(400)
lv1 := vcl.NewListView(mainForm)
lv1.SetParent(mainForm)
lv1.SetAlign(types.AlTop)
lv1.SetRowSelect(true)
lv1.SetReadOnly(true)
lv1.SetViewStyle(types.VsReport)
lv1.SetGridLines(true)
col := lv1.Columns().Add()
col.SetCaption("序号")
col.SetWidth(100)
col = lv1.Columns().Add()
col.SetCaption("项目1")
col.SetWidth(200)
lv1.Items().BeginUpdate()
for i := 1; i <= 20; i++ {
item := lv1.Items().Add()
item.SetCaption(fmt.Sprintf("%d", i+rand.Int()))
item.SubItems().Add(fmt.Sprintf("值:%d", i+rand.Int()))
}
lv1.Items().EndUpdate()
lv1.SetOnAdvancedCustomDrawItem(ListViewAdvancedCustomDrawItem)
lv1.SetOnAdvancedCustomDrawSubItem(lvTraiAdvancedCustomDrawSubItem)
vcl.Application.Run()
}
func lvTraiAdvancedCustomDrawSubItem(sender *vcl.TListView, item *vcl.TListItem, subItem int32,
state types.TCustomDrawState, stage types.TCustomDrawStage, defaultDraw *bool) {
canvas := sender.Canvas()
switch subItem {
case 0:
canvas.Brush().SetColor(0x02E0F0F7)
default:
canvas.Brush().SetColor(0x02F0EEF7)
}
}
func ListViewAdvancedCustomDrawItem(sender *vcl.TListView, item *vcl.TListItem, state types.TCustomDrawState, Stage types.TCustomDrawStage, defaultDraw *bool) {
sender.Canvas().Brush().SetColor(colors.ClRed)
}
from govcl.
前面我就是这么弄的:),就是感觉有点啰嗦,要写两个方法,如果没有其它更好的办法,就先这么弄吧,多谢了。
from govcl.
Related Issues (20)
- 再请教下ui的问题。 HOT 9
- MessageBox按钮只能ok和cancal吗
- Run和Build的时候的警告信息(macos 10.15 intel) HOT 1
- sample ListboxCustomdraw exit status 0xc000041d HOT 2
- 申请添加一个template到项目主页 HOT 1
- 整合WebView2 HOT 1
- 自定义GoVCL组件安装后看不到选项卡 HOT 6
- 请教想动态配置AnchorSide*()? HOT 2
- 请教个非govcl的问题:如何避免按钮重复点击事件 HOT 3
- 求助关于系统托盘左键使用菜单问题 HOT 1
- 关于开发调试 HOT 5
- fileshelltree例子中怎么按文件类型获取系统原生的图标 HOT 4
- Lazarus安装res2go组件报错问题 HOT 1
- MacOS13.3错误 HOT 7
- 使用garble代码混淆工具混淆后, 事件无法被调用 HOT 1
- 这个怎么感觉跟delphi的那个挺像的,能在delphi直接开发吗 HOT 1
- TListView滚动至底部 HOT 1
- 想实现一个检索窗口,如图。输入框输入内容,在输入框下方显示一个窗口用来显示检索结果,点击可以选中相应内容,这个是用到哪个组件 HOT 2
- Setting color colors.ClGray to canvas pen or brush of a form struct which has colorbox and toolbar field, crashes the program. HOT 2
- 请问这个背景颜色可以设置吗 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from govcl.