listbox 多列数据的问题,高手来

listbox多列数据的问题,高手来vb6.0中,listbox可以通过设置columns属性设置为多列显示,但设置为多列后如何为每一列赋值(或读取每一)列的数据?如何通... listbox 多列数据的问题,高手来

vb6.0中,listbox 可以通过设置columns属性设置为多列显示,但设置为多列后如何为每一列赋值(或读取每一)列的数据?
如何通过API取得外部程序中 多列listbox的数据?

1-3楼的都不对,2楼的,如果数据长度不一样,或者里面有汉字,你那个就不能用了
还有使用 LB_SETTABSTOPS 消息的也不考虑

如果有人能解决这个问题,愿意再加200分

不要跟我提listview,不考虑

可以参考这个:http://hi.baidu.com/%B7%BF%B6%F7%BA%EA/blog/item/3855eb2abdbe50325343c197.html
展开
 我来答
ljl88900
推荐于2016-02-19 · TA获得超过2660个赞
知道大有可为答主
回答量:2197
采纳率:100%
帮助的人:2592万
展开全部

把下面代码保存为“Form1.frm”,然后打开该文件,运行即可看到效果。

VERSION 5.00

Begin VB.Form Form1 

   BorderStyle     =   3  'Fixed Dialog

   Caption         =   "Form1"

   ClientHeight    =   3960

   ClientLeft      =   45

   ClientTop       =   435

   ClientWidth     =   7695

   LinkTopic       =   "Form1"

   MaxButton       =   0   'False

   MinButton       =   0   'False

   ScaleHeight     =   3960

   ScaleWidth      =   7695

   StartUpPosition =   3  '窗口缺省

   Begin VB.CommandButton Command2 

      Caption         =   "写入列数据"

      Height          =   495

      Left            =   4200

      TabIndex        =   4

      Top             =   3240

      Width           =   1575

   End

   Begin VB.ListBox List2 

      Height          =   2580

      Left            =   5520

      TabIndex        =   3

      Top             =   120

      Width           =   2055

   End

   Begin VB.ListBox List1 

      Columns         =   10

      Height          =   2580

      Left            =   120

      TabIndex        =   1

      Top             =   120

      Width           =   5295

   End

   Begin VB.CommandButton Command1 

      Caption         =   "获取列数据"

      Height          =   495

      Left            =   2280

      TabIndex        =   0

      Top             =   3240

      Width           =   1575

   End

   Begin VB.Label Label1 

      Caption         =   "Label1"

      Height          =   255

      Left            =   120

      TabIndex        =   2

      Top             =   2760

      Width           =   5175

   End

End

Attribute VB_Name = "Form1"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

Option Explicit

Private Sub Command1_Click()

Dim i As Integer, N As Integer, Counts As Integer

    N = InputBox("你要获取第几列数据", Command2.Caption, 2)

    If N = 0 Or List1.ListCount = 0 Then Exit Sub

    List2.Clear

    Counts = List1.Height / Me.TextHeight("a")    '每列记录数

    For i = (N - 1) * Counts To (N - 1) * Counts + Counts - 1    '第N列数据范围

        List2.AddItem List1.List(i)

    Next

End Sub

Private Sub Command2_Click()

Dim i As Integer, N As Integer, Counts As Integer

    N = InputBox("你要写入第几列数据", Command2.Caption, 2)

    If N = 0 Or List1.ListCount = 0 Then Exit Sub

    List2.Clear

    Counts = List1.Height / Me.TextHeight("a")    '每列记录数

    For i = (N - 1) * Counts To (N - 1) * Counts + Counts - 1    '第N列数据范围

        List1.List(i) = Format(Rnd * 100, "0000")

    Next

End Sub

Private Sub Form_Load()

Dim i As Integer

    Randomize

    For i = 1 To 100

        List1.AddItem Format(i, "0000")

    Next

End Sub

Private Sub List1_Click()

    Label1 = List1.ListIndex + 1 & ":" & List1.Text

End Sub

cwa9958
2010-08-28 · TA获得超过1884个赞
知道大有可为答主
回答量:2504
采纳率:0%
帮助的人:1984万
展开全部
多列与单列是一样的,也是按顺序显示的

取出数据也是用
List1.List(List1.ListIndex)

List1.Text
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
贵大人呗
2010-08-28 · TA获得超过285个赞
知道小有建树答主
回答量:265
采纳率:0%
帮助的人:277万
展开全部
我想因该是通过数组吧!在网上搜搜!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式