I have done for clicking one the datagridview row cell in one form say form 1 another form say form 2 will open along with selected data grid view data on form1..
I am using winforms...c#
i have done some operations on datagrid view data and at the end of the operations stage the form2 will be closed
NOTE :upto this i have finished
i want to update the datagridview in form1 with changes i have done in form2
for that i have done like this..
form 1:
private void productGridview_Cellclick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex != productgridview.Columns["productimage"].Index) return;
if (productgridview.SelectedCells.Count == 0) return;
int selectedrowindex= productgridview.SelectedCells[0].RowIndex;
DataGridViewRow selectedRow = productgridview.Rows[selectedrowindex];
if (img is Image)
{
using (ProductDescriptionForm pf = new ProductDescriptionForm())
{
pf.picture = img;
pf.productname = productname;
pf.description = desc;
pf.productprice = productprices;
pf.categoryname = categoryCombobox.Text;
pf.productid = productids;
pf.ShowDialog(this);
}
}
}
and in form2 : I have done like this ...
public int productid
{
get { return _prodid; }
set { _prodid = value; }
}
public Image picture
{
get { return pictureBox1.Image; }
set { pictureBox1.Image = value; }
}
like this some constructors i have used and then
i have deleted one row in datagridview by using below code ...its fine..
private void btnProdDelete_Click(object sender, EventArgs e)
{
using(var context = new TsgEclipseEntities())
{
var pd = new product(){ product_Id = productid };
context.products.Attach(pd);
context.DeleteObject(pd);
context.SaveChanges();
this.Close(); // form2 close
}
}
now i want to update the datagridview in form1 how i have to do that .....
can any one have idea about this ...
many thanks....
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…