Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Datagridview: Cell with more than one value from DB is readonly, what can i do?
 

Datagridview: Cell with more than one value from DB is readonly, what can i do?

I have a datagridview with a DataTable as Datasource. 

One value in the select-Statement is build like this: value1 + '|' + value2 as value.

I use the values for different things: First value is the string to be shown, based on the second value i set the background-color of the cell... (works fine with the paint method of the cell).

Now I have a form which is shown by the onMouseClick-Event. From here i can set new values and write them back to the DB, and then i want to set the new value to the current Cell to redraw the cell with the new value, but its readonly. I don't need to save the value from here to the db, its  already done.

If your answer includes virtual mode, please remember that i have to call a form to edit data. (I have looked at this, but i don't know  if this is really that what i want. )

phil

 

 

phil_t50  Monday, June 12, 2006 10:39 AM

I have done it.

I don't have set a Datasource to the grid.
I have done it manually.

e.g:

while dr.read

newRow = datagridview.Rows.add

datagridview.Rows(NewRow).Cells("id").Value = dr.Item("id")

end while

now its like a "offline recordset"

(not a working example!)

phil

phil_t50  Monday, June 19, 2006 3:31 PM

Why not try DataGridView.Refresh() or DataGridView.Invalidate? If the datatable has already been changed, if its not already refreshing automatically, it shoud.

However, if your datatable is not automatically refreshing with the database, try recalling whatever function you called to load it, and then call refresh or invalidate to make the dgv display the updated data.

Andrew McGhie  Monday, June 19, 2006 3:55 PM

You can use google to search for other answers

Custom Search

More Threads

• DataGridView wont update cell template
• No append Row
• Custom DataGridView cell
• How to edit the datagrid items(rows and columns) in vb.net window application
• DataGrid Cells
• flex grid functions
• How to delete Multiple rows from DGV?
• Advice needed on changing database schema after deployment
• database filepath problem
• ColumnHeadersDefaultCellStyle.Alignment