By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,839 Members | 2,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,839 IT Pros & Developers. It's quick & easy.

DataGridView Column

P: n/a
Ok, this is an odd one, but I could use some assistance with the
framework 2 in VB.Net...

I want to have a DataGridViewColumn, only have it use the ComboBox, then
when they drop down the combobox, open up another datagridview instead
of the combobox dropdownlist. The reason I want to do this, is so I can
show more than one column at a time in the drop down list. Instead of
trying to make a multi-column combo, I thought it would be much better
to use a DataGridView.

I have it close, but not quite working... One thing I ran into, was that
if I add the DataGridView to the DataGridEditingControl, the grid will
only display in the cell, and not outside of it.. Probably because it's
inside it and using it as a container. So, what I tried next is to add
it to the controls collection of the ParentContainer (which ends up
being the form) ... Aside from a location issue, this seems to work,
with one flaw.... If you try to click in the grid, the combo box loses
focus and closes (which destroys the editing control and closes the
grid) ....

I was going to attempt to just create a editing control from scratch and
inherit from the DataGridView, but then how do you tie a combobox to it
for the "dropdown" arrow, and get it set to a seperate datasource than
what the parent DataGrid is attached to?

As a note, this main datagrid shows a list of that has one field that is
just an ID out of a second table. The second table has this ID field,
but also a user entered ID field plus descriptions and names. In the
drop down, I don't want to see the ID, I want to see the user entered ID
and names...

Any suggestions?
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Aaron,

I think that this is an interesting question for this newsgroup.

http://forums.microsoft.com/MSDN/default.aspx

Your question in that can help to improve the documentation.

Cor
Nov 21 '05 #2

P: n/a
Cor,

I already posted a message in there about it. Those forums do not get
the exposure that these groups get so I was posting my question here as
well to try to reach as many people as I can.

I'm also considering setting up a gotdotnet workspace for this code so I
can try to get others involved in updating/modifying the code. I think
this is something that a lot of people would like to use.

Aaron

Cor Ligthert wrote:
Aaron,

I think that this is an interesting question for this newsgroup.

http://forums.microsoft.com/MSDN/default.aspx

Your question in that can help to improve the documentation.

Cor

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #3

P: n/a
If anyone wants to try to help out, here is the code so far:

Public Class DataGridViewDropGridColumn
Inherits DataGridViewComboBoxColumn
Dim DropGridCell As DataGridViewDropGridCell

Public Overrides Function Clone() As Object
Dim newObj As DataGridViewDropGridColumn = MyBase.Clone()
Return newObj
End Function

Public Sub New()
DropGridCell = New DataGridViewDropGridCell()
MyBase.CellTemplate = DropGridCell
End Sub
End Class

Public Class DataGridViewDropGridCell
Inherits DataGridViewComboBoxCell

Public Overrides Function Clone() As Object
Dim newObj As DataGridViewDropGridCell = MyBase.Clone()
Return newObj
End Function

Public Overrides Sub InitializeEditingControl(ByVal rowIndex As
Integer, ByVal initialFormattedValue As Object, ByVal
dataGridViewCellStyle As DataGridViewCellStyle)
' Set the value of the editing control to the current cell value.
MyBase.InitializeEditingControl(rowIndex,
initialFormattedValue, dataGridViewCellStyle)
Dim ctl As DataGridViewDropGridEditingControl =
CType(DataGridView.EditingControl, DataGridViewDropGridEditingControl)
ctl.GridView.DataSource = Me.DataSource
ctl.Text = CType(Me.Value, String)
End Sub

Public Overrides ReadOnly Property EditType() As Type
Get
Return GetType(DataGridViewDropGridEditingControl)
End Get
End Property

Public Overrides ReadOnly Property ValueType() As Type
Get
Return GetType(Decimal)
End Get
End Property
End Class

Public Class DataGridViewDropGridEditingControl
Inherits DataGridViewTextBoxEditingControl
Dim grid As DataGridView

Property GridView() As DataGridView
Get
Return grid
End Get
Set(ByVal value As DataGridView)
grid = value
End Set
End Property

Private Sub DataGridViewDropGridEditingControl_Click(ByVal sender
As Object, ByVal e As System.EventArgs) Handles Me.Click

End Sub

Private Sub DataGridViewDropGridEditingControl_DropDown(ByVal
sender As Object, ByVal e As System.EventArgs) 'Handles Me.DropDown
Dim iIndex As Integer
Dim frmParent As Form

frmParent = Me.EditingControlDataGridView.GetContainerControl( )
grid.Left = Me.Parent.Left
grid.Top = Me.Parent.Top
frmParent.Controls.Add(grid)
iIndex = frmParent.Controls.GetChildIndex(grid)
frmParent.Controls(iIndex).BringToFront()
grid.Show()
End Sub

Private Sub DataGridViewDropGridEditingControl_DropDownClosed( ByVal
sender As Object, ByVal e As System.EventArgs) 'Handles Me.DropDownClosed
Dim frmParent As Form
frmParent = Me.EditingControlDataGridView.GetContainerControl( )
grid.Hide()
frmParent.Controls.Remove(grid)
End Sub

Public Sub New()
grid.AutoGenerateColumns = True
End Sub
End Class
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #4

P: n/a
s p

Aaron, any progress to your problem?

I'm working in VB.NET 2005's DataGridView, I too facing the same
problem, where the DataGridView build in type that is
DataGridViewComboBoxColumn does not support multi-column drop down list.

Can anyone HELP?????

*** Sent via Developersdex http://www.developersdex.com ***
Mar 10 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.