当以编程方式添加项目时,ListView不会滚动

时间:2017-12-12 13:17:10

标签: winforms

我有一个listView我在for循环中添加了许多按钮。但是,即使我将listView设置为scrollablescrollable也不会listview。我不确定为什么会这样。我只是在每次进入for循环时添加一个按钮,但是一旦在 ListViewTemplates.HeaderStyle = ColumnHeaderStyle.None For i As Integer = 1 To level3Cat.Count counter = i Mod 2 If counter = 0 Then Dim picture As Button = New Button() picture.Location = New System.Drawing.Point(165, topForNextControl) picture.Size = New System.Drawing.Size(90, layoutTemplateHeight) picture.TabStop = False picture.BackgroundImageLayout = BackgroundImageLayout.Stretch picture.BackgroundImage = My.Resources.XButton ListViewTemplates.Controls.Add(picture) topForNextControl += layoutTemplateHeight + HeighScaleFactor Else Dim picture As Button = New Button() picture.Location = New System.Drawing.Point(35, topForNextControl) picture.Size = New System.Drawing.Size(90, layoutTemplateHeight) picture.TabStop = False picture.BackgroundImageLayout = BackgroundImageLayout.Stretch picture.BackgroundImage = My.Resources.XButton ListViewTemplates.Controls.Add(picture) End If ListViewTemplates.Scrollable = True ListViewTemplates.View = View.Details counter += 1 Next 上有太多按钮无法查看,就会出现无滚动条。我的代码如下。

var customers = [{
            "Name" : "John",
            "Items" :[
                {"Fruits" : "Apple"},{"Fruits" : "Orange"}]
            },{
                "Name" : "Sam",
            "Items" :[
                {"Fruits" : "Pear"},{"Fruits" : "Nuts"}]
            },{
                "Name" : "Eric",
            "Items" :[
                {"Fruits" : "Banana"},{"Fruits" : "Raisins"}]
            }];
 for(i=0; i<=customers.length; i++){
 for(a=0; a<=customers.length; a++){
     alert(customers[i]["Items"][a]);
 }
}

0 个答案:

没有答案