Hi everyone,
I have a minor problem with one of my assignments. I want my child form to show defalut values on open. When i update the data or change the existing data i want it to be saved and then when i reopen the form i want those values to be shown. To elaborate more, I have a parent form and child form. When i select an item from a combo box in parent form and click on update button, the child form opens and shows default values. And then when i change the default values and click the update button in the child form the values need to be changed. So when i close the child form and reselect the same product and click update from parent form. The new values need to be shown. I am attaching a link to my code. Please take a look
Loading
kiran kumarPosted Feb 21, 2010, 2:25 AM
Thomas AndersonPosted Feb 21, 2010, 2:03 AM
kiran kumarPosted Feb 21, 2010, 1:57 AM
Thomas AndersonPosted Feb 20, 2010, 5:23 PM
Raaj KumarPosted Feb 18, 2010, 3:17 AM
I did few minor changes in your code and now it is working. In the application, when you update the ProductForm you are updating only the local array field
pObjBeta[sLFTwo.productCombo.SelectedIndex].productCategory = categoryCombo.SelectedItem.ToString();
which is visible only to this product page. So you have to reassign the productCategory to the main page which I have done.
Please let me know if you face any more problem.
Regards,
Raaj
kiran kumarPosted Feb 18, 2010, 2:21 AM
//PARENT FORM CODE
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace parchild
{
public partial class Form1 : Form
{
string bb = "";
public Form1()
{
InitializeComponent();
}
public void getchid(string add)
{
bb=add;
}
private void Form1_Load(object sender, EventArgs e)
{
string[] com = { "kiran", "kkk", "kumar"};
string[] com2 = new string[com.Length + 1];
com.CopyTo(com2, 0);
com2.SetValue(""+bb+"",com.Length);
for (int i = 0; i < com2.Length; i++)
{
comboBox1.Items.Add(com2[i]);
}
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
this.Hide();
f2.Show();
}
}
}
//CHILD FORM CODE
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace parchild
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string s = textBox1.Text;
Form1 f1 = new Form1();
f1.getchid(s);
this.Hide();
f1.Show();
}
}
}
MARK THE ANSWER IF IT HELPED YOU