about datagridview - vb.net

I have a form that I want to add the content of the datagridview to a listbox every time I double clik on the cell of the datagridview, then store the contents of the listbox in my database. please help.

Use the cellclick event off the datagridview, http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellclick.aspx
Then implement a "system"(session or something) that keeps track of the clicks when the amount of clicks = 2, add the cell value to your listbox and reset the counter to 0.
When do you want the storing of the contents in the listbox to occure?

Related

How to load items from combox into datagridview

How can I get items from combobox in to datagridview and when i click on a cell in datagridview it will lead me to edit so i'm thinking for edit when user clicks on a cell i will display its raw item in texbox and when user press enter it will change in in datagridview as well as in combox
how should i do this in vb.net
You will need to be more clear with your question.
But, for example if you have some items in your ComboBox you can copy them to DGV like this:
For Each item In ComboBox.Items 'loops over combobox
DataGridView.Rows.Add(item) 'adds a new row to datagridview and puts a value from combobox in it
Next

Setting ComboBox RowSource property to query in "GotFocus()" method leaves blank values in ComboBox Access VBA

I want to populate my ComboBox in an Access form using VBA based on data from another table. Previously to do this I did the following:
In the Property Sheet -> Data tab I filled out Row Source and Row Source Type fields with this information:
Now whenever I clicked on the dropdown for my combobox, it would populate the dropdown list with all of the names from t_people table.
This limited me however to when data changed in the t_people's name column. In order to get an updated list, I must close the form and re-open it so that the query runs again. I have limited the access to this Access file so that the user is only presented with x number of forms, and cannot close/open them or others.
My solution is to remove the query on the form load, and instead run the query every time the combobox gains focus, has a click event or something of the same sorts. I did this with the following event in VBA:
'Run when the "name" combobox gains focus
Private Sub nameCb_GotFocus()
[nameCb].RowSource = "SELECT name FROM t_people"
End Sub
I have set breakpoints and this code does run. However, the the combobox is not populated after it does. How can I get the combobox to populate with the values from a query for each time the combobox gains focus?
Set the RowSource in design and add a .Requery when entering the control.
Private Sub nameCb_Enter()
nameCb.Requery
End Sub

DataGridView ComboBox Cell error when closing form

I have a ComboBox column on my datagridview, the ComboBox is bound to a datasource for the values.
On Form Load I add rows and data to my DataGridView from a database table, here's how I add the value to the combobox column. This code is inside a loop, hence the rowindex variable.
Dim combo As DataGridViewComboBoxCell
combo = CType(Me.DataGridView1(3, rowindex), DataGridViewComboBoxCell)
combo.Value = sqldr("company_code")
It works fine for me, the combobox value is changed to what I had in my table and I can change the value of the cell using the combobox but if I try closing the form I get this error which just keeps repeating if I press Ok, I have to stop debugging just to exit the application.

VBA listview subitems

How can I save value to a selected item on listview from a multiple textbox, so that whenever I move to another value on listbox and then get back to the previous value, all of the multiple textbox will populate the saved inputs in textbox.

How to make custom Combo box control which have contain datagrid in vb.net

I want to make custom combo box which have contain datagrid and textbox too.
On clicks into combo box datagridview should be appear and selecting any row particular cell value of the datagridview added on the combo.
thanks in advance..
As your question is written I have no idea how to answer it, I can't figure out how you could sensibly show a DataGridView inside a ComboBox. I'm writing this answer with the assumption that you mean that the form should have a ComboBox that are "linked" to a DataGridView rather than actually contain it.
If so, all you need to do is to add the ComboBox and DataGridView to the form, make the DataGridView invisible. Then you handle the SelectedIndexChanged event for the ComboBox, in the handler, make the grid visibile, find the index of the row and column you want to show and write code like (code not tested so might not be correct):
grid.SelectedRows.Clear()
grid.FirstDisplayedScrollingRowIndex = rowIndex
grid.Rows(rowIndex).Cells(colIndex).Selected = True
grid.Show()