开发者

not able to transfer all valuesof particular selected row in datagrid view to another form

I have done like this for sending gridview row values from one form to another

i have datagrid view with columns productdescription , productimage , productname

my main aim is if, i select the image cell in datagridview the selected image and the values of row which row has that image need to send to another form ...

in the below code only image will be transferred to another form i need to send another values also ..开发者_JAVA百科.

i have searched a lot but i didnot find any solution.. and the code is given below....

      private void productGridview_Cellclick(object sender, DataGridViewCellEventArgs e)
      {
        byte[] bits = null;
        Image img = null;

            if (e.ColumnIndex != productgridview.Columns["productimage"].Index) return;

            if (productgridview.SelectedCells.Count == 0) return;

            bits = (byte[])productgridview.SelectedCells[0].Value;
            img = bytearraytoimage(bits);


            if (img is Image)
            {
                using (ProductDescriptionForm pf = new ProductDescriptionForm())
                {
                    pf.picture = img;



                    pf.ShowDialog(this);
                }
            }

    }

and in productdescription form i have defined like this ...

   public partial class ProductDescriptionForm : Form
   {
     public ProductDescriptionForm()
    {
        InitializeComponent();
    }

    public Image picture
    {
        get { return pictureBox1.Image; } 
        set { pictureBox1.Image = value; }
    }


}

how do i transfer other values in the same row that has the image to another form

I am using winforms....

many thanks in advance....

do i need to change the cell click event to row click event ?????

if so , how do i check the particular cell with image in datagridview

would any suggestions any bit of code would be helpful to me


This doesn't sound from object orientated but hey;

@marshal thanq for ur help i got the answer ..see my answer int selectedrowindex= productgridview.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = productgridview.Rows[selectedrowindex]; string desc = Convert.ToString(selectedRow.Cells["productdescr"].Value); by using above statements i got the values and I transferred to another form... – user852714


I have solved My problem by using the following way

int selectedrowindex= productgridview.SelectedCells[0].RowIndex;
DataGridViewRow selectedRow = productgridview.Rows[selectedrowindex];
string desc = Convert.ToString(selectedRow.Cells["productdescr"].Value);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜