How to make custom Combo box control which have contain datagrid in vb.net - 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()

Related

MS Access: listbox appears to be locked when assigned to ID's on continous form

I have a continuous form where i have a listbox assigned to an ID. I cant seem to select anything in the list box. I have the row source property set to a Value List. I manually typed in "Y";"N" for the list.
If I don't assign the control source to the ID, all listboxes are selected at once on the form.
Is there any property I should change?
Thanks
You cannot sensibly use unbound controls on a continuous form.

vb datagridview columntype change on edit

is there a method of setting up my datagridview to show me textboxcolumns until editmode is entered? At which time I will swap some textboxcolumns for bound comboboxcolumns. And at the end of validation/exit edit mode I can swap back?
If there's a method of doing this please share some links to examples.
I wouldn't try to switch DataGridView ColumnTypes like that. Sounds like a bad time.
Is your goal to have a DataGridViewComboBoxColumn that does not display the ComboBox dropdown button when it's not being edited? If so, there are two options:
Set the column's DataGridViewComboBoxColumn.DisplayStyleForCurrentCellOnly property to True.
Create your own DGV column based on the ComboBox by extending DataGridViewTextBoxCell. MSDN has a great article for doing this with the Calendar control here.
Of course you can. In the properties of the datagridview you can drill down to the column proprieties and switch the datatype to combo box. Very straight forward and easy.

change the list of combobox A based on the item chosen from combobox B

I am new to vb.net and I am using visual studio 2010. I have two comboboxes on a form, each combobox is set to DropDownList so that a list of items can show in the combobox, but no text is allowed to be entered.
For combobox A, if user chooses item 1, the list of combobox B should be updated accordingly. I think this is quite common on a lot of applications. But I do not know to implement it. I even do not know the keyword to search for the relevant property or event handler.
Thanks a lot!
Take a look at SelectedValueChanged. You can subscrive to this event on your first combobox, then when the event is raised, you can combo2.Items.Clear () the 2nd collection, then add your items.

Duplicate a DataGridView on a second windows form

I have a bound DGV that took a bit of work to get its columns set up. I'd like to show a 1-row version of this identical DGV on a second windows form. Is there a way to programatically place a copy on the second form. I would adjust the height and position of the 1-row version, and create a new binding source on the second form so that I could filter the data.
MyForm.Controls.Add(myDataGridView)
So further explanation:
In your first for you will need to make a variable or property that contains a reference to the DataGridView that you want to access.
I'd suggest doing something like this.
Public Shared Property myDataGridView As DataGridView
then after you get it set up in the form the way you want it set up
myDataGridView = originalDataGridView
Then in the second form
SecondForm.Controls.Add(FirstForm.myDataGridView)
Will add the DataGridView exactly as it is on the first form.
Edit
If you are creating it in a designer, you can just either copy and past it from the original for to the second form.
Or just on the Form.Shown or in the New() of the first form set the myDataGridView to the DataGridView that you created.

Changing styling of DataGridViewComboBoxCell from DropDownList to DropDown?

(This question is narrower in scope than this question I asked earlier.)
Say I have a DataGridViewComboBoxColumn, and want to switch the style of the ComboBox control between DropDownList and DropDown (mainly for the text field editing capability). I'd like to do this on a row-by-row basis (at the DataGridViewComboBoxCell level).
How would I do that programatically?
Or maybe a different way of asking: How do I access the ComboBox control given an object of type DataGridViewComboBoxCell?
(I'm in VB 2005.)
Thanks as always.
Not sure if you still need an answer, but i have a question that covers similar ground: Detect which column is showing an editing control in a datagridview
i use something like this line to get the combobox out of the DataGridView (DGV) in my DataGridView's CellValidating event:
Dim comboBox As DataGridViewComboBoxCell = DGV.Item(e.ColumnIndex, e.RowIndex)
later i use this line to get change the DropDownList ComboBoxCell to a DropDown:
cb.DropDownStyle = ComboBoxStyle.DropDown
For mine to work i had to make sure the 'cb' was of the ComboBox type, i dont remember if i was able to get it working well if the combobox was of the DataGridViewComboBoxCell type.