Giter Site home page Giter Site logo

虚表 ListView about govcl HOT 9 CLOSED

huang1120 avatar huang1120 commented on August 23, 2024
虚表 ListView

from govcl.

Comments (9)

ying32 avatar ying32 commented on August 23, 2024

测试并无问题啊,不知道你是怎么操作的。

这是我使用listviewvirtualdata例子测试的代码:

data := TTempItem{Caption: "标题", Sub1: "子项1", Sub2: "子项2", Sub3: "子项3", Sub4: "子项4", Sub5: "子项5", Checked: false}
tempData = append(tempData, data)
f.ListView.Items().SetCount(int32(len(tempData)))

from govcl.

huang1120 avatar huang1120 commented on August 23, 2024

` f.isWindows = runtime.GOOS == "windows"
fmt.Println("OnCreate")
f.SetWidth(800)
f.SetHeight(600)
f.ScreenCenter()
f.SetDoubleBuffered(true)

//============重绘表显示
f.Timer1 = vcl.NewTimer(f)
f.Timer1.SetOnTimer(f.OnTimer1Timer)
f.Timer1.SetEnabled(true)
f.Timer1.SetInterval(1000)
//==========================

f.ListView = vcl.NewListView(f)
f.ListView.SetAlign(types.AlClient)
f.ListView.SetParent(f)
f.ListView.SetViewStyle(types.VsReport)
f.ListView.SetOwnerData(true)
f.ListView.SetGridLines(true)
f.ListView.SetReadOnly(true)
f.ListView.SetRowSelect(true)
f.ListView.SetOnData(f.OnListView1Data)

// 要显示状态图标就得添加
// lazarus 2.2又出新bug了,,windows下ownerdata时会异常
f.ListView.SetCheckboxes(!f.isWindows)
//f.ListView.SetCheckboxes(true)

// windows下OwnerData不能显示checkbox
// linux和macOS在OwnerData下支持显示CheckBox
if f.isWindows {
	// 这里模拟显示
	f.stateImages = vcl.NewImageList(f)
	bmpFileName := "checkbox.png"
	if rtl.FileExists(bmpFileName) {
		pic := vcl.NewPicture()
		pic.LoadFromFile(bmpFileName)
		f.stateImages.AddSliced(pic.Bitmap(), 1, 2)
		pic.Free()
	}
	f.ListView.SetStateImages(f.stateImages)
	f.ListView.SetOnMouseDown(f.OnListView1MouseDown)
}

col := f.ListView.Columns().Add()
col.SetCaption("行号")
col.SetWidth(100)

col = f.ListView.Columns().Add()
col.SetCaption("子项1")
col.SetWidth(100)

col = f.ListView.Columns().Add()
col.SetCaption("子项2")
col.SetWidth(100)

col = f.ListView.Columns().Add()
col.SetCaption("子项3")
col.SetWidth(100)

col = f.ListView.Columns().Add()
col.SetCaption("子项4")
col.SetWidth(100)

col = f.ListView.Columns().Add()
col.SetCaption("子项5")
col.SetWidth(100)

//=============================== 这里 生成一个数据 下面就会出现 不会刷新 如果你生成2个数据就正常
tempData = make([]TTempItem, 1)
t := time.Now().UnixNano()
for i := 0; i < len(tempData); i++ {
	tempData[i].Caption = fmt.Sprintf("%d", i+1)
	tempData[i].Sub1 = fmt.Sprintf("子项1:%d", rand.Intn(1000000))
	tempData[i].Sub2 = fmt.Sprintf("子项2:%d", rand.Intn(1000000))
	tempData[i].Sub3 = fmt.Sprintf("子项3:%d", rand.Intn(1000000))
	tempData[i].Sub4 = fmt.Sprintf("子项4:%d", rand.Intn(1000000))
	tempData[i].Sub5 = fmt.Sprintf("子项5:%d", rand.Intn(1000000))
	tempData[i].Checked = false
}
go func() {
	index := 0
	for {
		vcl.ThreadSync(func() {
			// 这里目前是1 不会正常刷新显示 如果上面生成2条数据以上就正常
			tempData[0].Sub5 = strconv.Itoa(index)

			//tempData[1].Sub5 = strconv.Itoa(index)
			index++
		})
		time.Sleep(time.Second * 1)
	}
}()`

from govcl.

ying32 avatar ying32 commented on August 23, 2024

你这更新数据内容,需要调用控件的重绘(Repaint)之类的方法。

from govcl.

huang1120 avatar huang1120 commented on August 23, 2024

我那个已经调用一秒重绘一次了,问题就是一行数据就不会重绘,两行以上的数据就正常,你可以测试一下就知道了

from govcl.

ying32 avatar ying32 commented on August 23, 2024

我用你这个代码测试了下,没有发现问题,可以正常更新。你可以考虑下用最新的lazarus重新编译下liblcl看看。

from govcl.

huang1120 avatar huang1120 commented on August 23, 2024

我这里如果是两条数据以上也是正常刷新的,就是一条数据的时候才不正常刷新,永远是0

from govcl.

ying32 avatar ying32 commented on August 23, 2024

刚准备上传个新的liblcl,发现不行哦,得自己编译的才可以。

from govcl.

huang1120 avatar huang1120 commented on August 23, 2024

还是不行,会不会是win11的问题?这个问题不大,但是我觉得很奇怪,解决不了就不管他了 ,反正不影响使用

from govcl.

ying32 avatar ying32 commented on August 23, 2024

不知道,我在win10上编译的

from govcl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.