我必须把类别(电影/电视)作为一行,并在一个专栏中奖励(喜剧,戏剧等)。用户将电影或电视剧的名称输入到名为TBseriesName的文本框中,并使用名为comboBoxCategory的组合框选择类别,并使用listBox选择用户想要给出的名为listBoxAwards的奖项。 我希望它在listView中显示如下:
Comedy Drama Animation Actor Actress Foreign Language
电视:这是我的尝试:
enter code here
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Windows.Forms;
namespace The_Woodberry_Awards
{
public partial class Form1 : Form
{
string[,] selection = new string[7, 2];
string[] category = {"Film","TV"};
string[] award = { "Comedy", "Drama", "Animation", "Actor", "Actress", "Foreign Language", "Special Effects" };
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
comboBoxCategory.Items.Add("Film");
comboBoxCategory.Items.Add("TV");
}
private void buttonSave_Click(object sender, EventArgs e)
{
//declare and store user inputs
int colPosition;
int rowPosition;
string seriesName;
seriesName = TBseriesName.Text;
rowPosition = listBoxAwards.SelectedIndex;
colPosition = comboBoxCategory.SelectedIndex;
selection[rowPosition, colPosition] = seriesName;
}
private void listBoxAwards_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void buttonClear_Click(object sender, EventArgs e)
{
listViewOutput.Clear();
}
private void buttonDisplay_Click(object sender, EventArgs e)
{
ListView.ColumnHeaderCollection col = new ListView.ColumnHeaderCollection(listViewOutput);
col.Add("Comedy ", 60, HorizontalAlignment.Right);
col.Add("Drama ", 60, HorizontalAlignment.Right);
col.Add("Animation ", 60, HorizontalAlignment.Right);
col.Add("Actress ", 60, HorizontalAlignment.Right);
col.Add("Foreign Language ", 60, HorizontalAlignment.Right);
col.Add("Special Effects ", 60, HorizontalAlignment.Right);
ListViewItem row = new ListViewItem();
ListViewItem column = new ListViewItem();
//display column headers
for (int i = 0; i < category.Length; i++)
{
row = listViewOutput.Items.Add(category[i]);
}
这是我在运行程序时显示的内容,但我没有展示如何在列中的每个类别之间留出空格或如何显示节目或电影的名称 enter image description here