Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
885 views
in Technique[技术] by (71.8m points)

.net - Multicolumn ListBox in WPF

I have 3 TextBoxes and 1 Button and want to enter each of the the TextBoxes data into a ListBox in separate columns.

I know how to enter data into one column:

listbox1.Items.Add(TextBox1.text);

but how can I enter the data into multiple columns?

I am using .NET WPF. I want to use a ListBox or a ListView.

my window

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You want a ListView instead:

Something like this:

<ListView ItemsSource="{Binding SourceCollection}">
    <ListView.View>
        <GridView>
            <GridViewColumn Header="Test1" DisplayMemberBinding="{Binding Test1}" />
            <GridViewColumn Header="Test2" DisplayMemberBinding="{Binding Test2}" />
            <GridViewColumn Header="Test3" DisplayMemberBinding="{Binding Test3}" />
            <GridViewColumn Header="Button">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <Button>Button Text</Button>
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
        </GridView>
    </ListView.View>
</ListView>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...