识别并填充列表框 [英] Identify and populate a listbox

查看:43
本文介绍了识别并填充列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这对我来说是个谜:填充列表框的语法是什么?但首先:您如何识别列表框?在许多论坛中,我读到:ListBox1.Additem...但他们怎么知道它是ListBox1"?

It's a riddle for me: what is the syntax to populate a listbox? But first: how do you identify a listbox? In many forums I read: ListBox1.Additem... But how do they know it's 'ListBox1'?

推荐答案

ListBox1.AddItem 用于加载单列 ListBox(CodyGrey 的回答涵盖了这一点).

ListBox1.AddItem is for loading a single column ListBox (CodyGrey's answer covers that).

如果您使用的是多列 ListBox(属性 .ColumnCount > 1),那么您需要将一个 Array 加载到 .List 中.以下代码段将 3 行加载到 2 列 ListBox

If you are using a multi column ListBox (property .ColumnCount > 1), then you need to load an Array into .List. The following snippet loads 3 rows into a 2 column ListBox

Dim dat(0 To 2, 0 To 1) As Variant

dat(0, 0) = "A"
dat(0, 1) = "B"
dat(1, 0) = "C"
dat(1, 1) = "D"
dat(2, 0) = "E"
dat(2, 1) = "F"

ListBox1.List = dat

<小时>

访问列表框:(这会因 Word 的不同版本而异,这是 2003 年的)


Accessing the List Box: (this will vary for different versions of Word, this is for 2003)

访问列表框属性:

  1. 显示控件工具箱"工具栏
  2. 进入设计模式
  3. 单击控件,然后在控件工具箱"中选择属性"
  4. Name 属性现在应该可见且可编辑
  5. 还可以设置其他属性,例如 ColumnCount 等

这篇关于识别并填充列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆