旅行表格,递送表格,提货表格
在主表单上的我有一个按钮,可以将您从输入一些数据的行程输入到文本框中,然后当您按添加它时,将根据您输入的数据添加一个提取或交付{{{主表单上的1}}
我如何获得它,以便如果我在主表单中向listbox
添加投放,它还会将投放添加到投放表单中的listbox
或者如果我在主要表单上的listbox
添加了一个提货,它还会在提货单上的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
答案 0 :(得分:0)
您可以在frmDelivery类中创建一个公共方法:
public void ListBoxAdd(string item)
{
listbox_frmDelivery.Items.Add(item); // or whatever your list box is called
}
然后在您初始化frmDelivery的主页中,您可以致电:
deliveryForm.ListBoxAdd("Added From Main Form by pub method");
或您可以在主表单上搜索它:
int indexOfListBox = deliveryForm.Controls.IndexOfKey("frmDelivery listbox id");
if (indexOfListBox != -1)// if not -1 we found it
{
ListBox deliveryListBox = (ListBox)deliveryForm.Controls[indexOfListBox];
deliveryListBox.Items.Add("Added from Main form by searching index");
}