行程表,發貨單,在主窗體上皮卡形式添加到數據到2個不同的列表框上的2種不同形式的
我有一個按鈕,把你的旅行從那裏你輸入一些數據轉換成文本,然後裝箱當你按添加它會或者添加一個皮卡或交付取決於你輸入到主表格
你輸入什麼數據我將如何得到它,所以如果我添加一個交貨到listbox
在主窗體中還將交貨添加到listbox
的交貨形式
或者如果我添加了pi ckup到listbox
上的主要形式,還增加了一個拾取到listbox
拾取形式
一些示例代碼如何我添加的遞送:
主要形式加入遞送按鈕:
private void btnDelivery_Click(object sender, EventArgs e)
{
deliveryForm.deliverytrips = new DeliveryTrips();
//New delivery- note added to the deliveryForm object
deliveryForm.ShowDialog();
//Show the deliveryForm. ShowDialog ensures that the form has the exclusive focus until it is closed.
if (deliveryForm.deliverytrips != null)
//if null then the "cancel" button was pressed
{
DeliveryTrips newApp = deliveryForm.deliverytrips;
//Get the delivery object from the form
theDelivery.addDeliveryTrip(newApp);
//Add the delivery to the summary
}
updateList();
//Update the list object to reflect the delivery in the summary
CODE FOR從到添加發送到列表框控件ON主要形式有:
public partial class frmDelivery : Form
{
private DeliveryTrips theDeliveryTrips;
//The DeliveryTrips object being created/edited
public DeliveryTrips deliverytrips
{ //Property to allow access to theDeliveryTrips
get { return theDeliveryTrips; }
set { theDeliveryTrips = value; }
}
public frmDelivery()
{ //Constructor
InitializeComponent();
}
private void frmDelivery_Load(object sender, EventArgs e)
{
//When makeing the form visible, set the text boxes to reflect the values in
//theDeliveryTrips.
if (theDeliveryTrips != null)
{
txtDescription.Text = "Delivery";
txtDescription.ReadOnly = true;
txtCustomerName.Text = theDeliveryTrips.customername;
txtCustomerAddress.Text = theDeliveryTrips.customeraddress;
txtTime.Text = theDeliveryTrips.arrivaltime.ToString();
}
}
private void btnAdd_Click_1(object sender, EventArgs e)
{
theDeliveryTrips.description = txtDescription.Text;
theDeliveryTrips.customername = txtCustomerName.Text;
theDeliveryTrips.customeraddress = txtCustomerAddress.Text;
theDeliveryTrips.arrivaltime = TimeSpan.Parse(txtTime.Text);
this.Hide();
//Hide the forum
}
private void btnCancel_Click_1(object sender, EventArgs e)
{
theDeliveryTrips = null;
//Set theDeliveryTrips to null as to remove any changes made
this.Hide();
//Hide the forum
}
}
您是否嘗試將它們全部設置爲使用相同的DataContext? –
我該怎麼做,即時通訊新的C#所以不長的開始學習如何編碼在C# – Michael
考慮使用反應式擴展。它也有一個調度程序,尊重UI上下文 –