data type from datagridview

I have a datagridview bound to an Acess DB. I want to set the values from the datagrid into a textbox and assign them to an integer variable.

Whatever I try I get the message that the datagrid cannot be converted into the necessary datatype (string or integer)

Help or please point me to a source.

Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pic.Click

'Draw line on picturebox

'Put a picturebox on the form named pic

Dim bit As Bitmap = New Bitmap(pic.Width, pic.Height)

Dim h As Integer

Dim w As Integer

Dim g As Graphics = Graphics.FromImage(bit)

Dim myPen As Pen = New Pen(Color.Blue, 3)

h = DGV1(5, 2)

w = DGV1(6, 2)

g.DrawLine(myPen, H, W, pic.Width, pic.Height)

pic.Image = bit

End Sub

Thanks,

DWR



Answer this question

data type from datagridview

  • Leon Jones

    h = DGVI.Item(5,2).Value

    w = DGVI.Item(6,2).Value

    A bit confusing at times. But, that should work if not. You may have to convert the cell value(s) to Integer.

    h = CInt(DVI.Item(5,2).Value

    w = Cint(DVI.Item(6,2).Value

    james

    aka:Trucker


  • vbjunkie

    hi,

    Is your problem solved

    Thank you,
    Bhanu.



  • data type from datagridview