我正在创建一个表单以保存来自“会议”的信息。用户将填写有关title
,location
,startTime
,endTime
,notes
和date
的信息。我目前的工作是“保存更改”按钮,它将:C#会议系统
- 清除所有文本框。
- 将输入存储在数组中。
- 只在列表框中显示
title
。 - 当在ListBox中点击标题时,如果用户希望进行更改,则存储在该数组元素中的信息将重新填充到相应的文本框中。
我已经完成#1,#2和#3我会很感激#4的帮助。我粘贴了以下代码供您查看。
public partial class CalendarForm : Form
{
int currentIndex;
int arraySize = 0;
Meeting[] meetingArray = new Meeting[100];
public CalendarForm()
{
InitializeComponent();
}
private void saveChangesButton_Click(object sender, EventArgs e)
{
meetingArray[arraySize] = new Meeting();
meetingArray[arraySize].title = textBoxTitle.Text;
meetingArray[arraySize].location = textBoxLocation.Text;
meetingArray[arraySize].startTime = textBoxStartTime.Text;
meetingArray[arraySize].endTime = textBoxEndTime.Text;
meetingArray[arraySize].notes = notesTextBox.Text;
currentIndex = arraySize;
arraySize++;
meetingListBox.Enabled = true;
textBoxTitle.Text = "";
textBoxLocation.Text = "";
textBoxStartTime.Text = "";
textBoxEndTime.Text = "";
notesTextBox.Text = "";
*edit* added these two lines which now add the title to the listBox
meetingListBox.Items.Add(meetingArray[currentIndex].title);
Controls.Add(meetingListBox);
}
}
public class Meeting
{
public string title;
public string location;
public string startTime;
public string endTime;
public string notes;
};
这不是一个人们为你编写代码的地方,你需要展示*你尝试过的*,如果你有任何具体的问题/问题,那么你将得到积极的回应。 – AbZy 2013-02-20 18:36:13
这里是我试过的:meetingListBox.Text = meetingArray [currentIndex]。标题; – PrgmRNoob 2013-02-20 18:39:02
虽然家庭作业标签现已过时,但您应该提及这是否是家庭作业。 – Pete 2013-02-20 18:40:03