473,396 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DataGridView Column

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
4 10027
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: dbuchanan | last post by:
Hello, Is this a bug? Is there some kind of work around? I want to add default values for a few columns in my datagridview I found the "DefaultValuesNeeded" event for the datagridview I...
1
by: mark carew | last post by:
Hi, Problem - An extra column to the left (even with row headers disabled) ---------------------------------------------------------- Apologies if this posting is already in the newsgroup; but...
1
by: Rich | last post by:
Hello, I am reading data from a sql server table that is under replication. This table has the replicatin GUID column that is generated with replicatin. I am reading the data from a...
4
by: Matt | last post by:
I have been searching all over the web for a way to sort a DataGridView based on the actual text being shown in a ComboBox column as opposed to the underlying value (an ID in this case). Can anyone...
7
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's...
3
by: sklett | last post by:
I'm changing from a DataGrid to a DataGridView and have run across a problem. The items that are bound to the DataGrid have an int Property that represents a primary key of a lookup table in my...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
18
by: Andrus | last post by:
Marc, Thank you very much. I have issue on implementing add row properly using this. User presses down arrow in last row in grid starting adding new row. Then user changes its mind desiding...
6
by: Miro | last post by:
Sorry for the cross post. I am stuck. I have a datagridview for poker rounds. Basically there are 3 columns in this datagridview. "Round" "SmallBlind" "BigBlind" I have an issue when I tab...
0
by: priyamtheone | last post by:
I'm trying to make a datagridview column to act like a datetimepicker column (C#.Net 2005). These are the behaviours that the dgv should have: 1) Initially all the cells of the dtp column should be...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.