hi people

how do I select a specific row in a data grid view to be updated. the row contains item number, item name and price.

thanks

Recommended Answers

All 13 Replies

Just search dani web with your query as there are lots of answers.

datagrid imports data from online or local?

hi

it collects data from the text boxes in the form.

this is really easy,

but dont have time to talk right now.. Im busy I can help you on skype, can send and code if is needed.

PS: a simple way to do this too is to do with tags.

PSS: skype account ID: altjen.ber

hi

thanks for the suggestion but I was wondering, what time can we arrange. my time zone is +3 GMT (East African time).

thanks.

same as mine. but we can talk when we can be free..

Im busy I can help you on skype, can send and code if is needed.

If you supply a solution via Skype then it doesn't help anyone else here. If you do this then please post the solution.

I can use skype from phone, but cant surf on this page from there. no idea why. (and use lumia 925)

and most of time Im on phone and less time on pc so for her problems I thought that could help from there, but also gave a good example how to get data from local db only with tags

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    DataGridView1.Rows.Add({"1", "Pizza", "$20.00"})
    DataGridView1.Rows.Add({"2", "Bun", "$1.00"})
    DataGridView1.Rows.Add({"3", "Burger", "$3.00"})
    DataGridView1.Rows.Add({"4", "Fries", "$2.00"})
    DataGridView1.Rows.Add({"5", "Chicken", "$2.50"})

End Sub

Private Sub DataGridView1_CellClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick

    txtNumber.Text = DataGridView1.Rows(e.RowIndex).Cells(0).Value
    txtName.Text = DataGridView1.Rows(e.RowIndex).Cells(1).Value
    txtPrice.Text = DataGridView1.Rows(e.RowIndex).Cells(2).Value

End Sub

I have set DataGridView1 with the following properties

DataGridView1.AllowUserToAddRows = False
DataGridView1.AllowUserToDeleteRows = False
DataGridView1.AllowUserToOrderColumns = True
DataGridView1.AllowUserToResizeRows = False
DataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect

Clicking any cell will cause the entire row to be selected and to copy the corresponding cell values to the text boxes for editing.

hi
thanks a lot. I was able to borrow a leaf from your code snippet to help implement my application. but I need extra assistance regarding getting the sum of the totals.
I have used:

dim sum as decimal
sum+ = daragridview1.rows( I).cells(2).value
textbox2.text=sum

but I have a problem, the column has got some null values and I get an error related to DBNull and as such I cannot get the sum.

thanks.

here is the error message. error: operator '+' is not defined for the type
DBnull and integer..

thanks

Does the associated cell have a value in it? If the data is originally from a database you may have to convert nulls to some default value. In MS SQL you can use the COALESCE function. If the null values are because a textbox field is empty then you'll have to ensure that all fields contain values.

hi
I got it. I used:
if not IsDBNull(datagridview1.Rows ( I).cells(2).value) Then
sum+=datagridview1.rows(I).cells(2).value
end if

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.