473,671 Members | 2,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic ComboBox in DataGridView

1 New Member
I have a VB application that's about 95% done. As usual, it's that last 5% that's got me stymied. The program is a Bill-of-material update program that interfaces with an SAP database. The BOM's relate to custom computer configurations. By the nature of a BOM, there are many lines, with many fields to each line. The program uses a DataGridView control to present the data. It is currently working ok with manually-keyed input. However, to make it user-friendly, it needs to use ComboBox dropdowns for the various selections. Therefore, several of the DataGridView columns need to include a combo box. This is where my problem lies.

Specifically, I have two issues: (1) getting the combo-box to populate from an SQL statement, and (2) getting subsequent combo-boxes on the same line to tailor their content based on the previous combo-box. To illustrate the second issue, if the first combo-box says that this particular row deals with data storage for the computer, then the only items that should be included in the second combo box would be those that are disk drives. Obviously, the selection and content of a control on one BOM line will be completely different from those on other rows.

I am able to dynamically load a standalone ComboBox, by setting the Display, Value, and DataSource (which returns a table) properties. However, I can't seem to accomplish this when the ComboBox is embedded in a DataGridView control.

Any help would be greatly appreciated.
Dave
Nov 5 '07 #1
3 2652
G Satish Kumar
8 New Member
Is your problem to get the combo box in the DataGridView?

If this is the issue I feel the below code could help you.

After

dataadapter.fil l(dataset)

if the column name is empGrade and this is the first column for which you require the column in the grid view as combo box then

dim colempgrade as new datagridviewcom boboxcolumn

colempgrade.dat apropertyname=d ataset.tables(0 ).column(0).toS tring()
colempgrade.nam e="employee grade"
colempgrade.dat asource='use the column name or list yyou want to populate the combo
datagridview.ad d.columns(colem pgrade)

Please ignore if this not what was not required

Satish
Nov 7 '07 #2
debasisdas
8,127 Recognized Expert Expert
What is the version of VB that you are using?
Nov 7 '07 #3
G Satish Kumar
8 New Member
What is the version of VB that you are using.
.NET 2005 is the version I am talking about. I think we have datagridview from 2005 only, the earlier version had only datagrid which lacked some of the enhancements compared to that of DGV.

Please check if you are using the same version I could give you the exact code for the requirement.

Satish
Nov 8 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
16335
by: Nathan | last post by:
Hi, I have a datagridview bound to a List of objects (ObjectA). Each ObjectA contains an ObjectB property. Class ObjectA { public ObjectB objB {} }
4
8628
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 tell me if this is even possible, and if so, how to do it? If this is completely impossible, how would you suggest going about sorting a ComboBox wherein the text displayed in the column is the client's name, and the underlying value is an ID? ...
8
26421
by: | last post by:
I am sure this has been asked and answered, but here goes anyway... VS.Net 2005, VB.Net How can you display more than one field in the displaymember property of a combobox inside the datagridview control? I am at a loss. Thanks, David
0
1165
by: c_shah | last post by:
I have the controls on my form display the values of the currently selected row of the DataGridView. I am binding my DataGridView to a collection (Collection - which implements IBindingList Interface). I am binding DataGridViewTextBoxColumn to the property of the objects in my collection. I have a combobox that should display a choice of ranges. Initiallly combobox should be bound to a different datatable from a look up table. How do...
3
94244
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 database. For example: table JobTypes 1 | Manager 2 | Controller 3 | Supervisor table Employee
3
14365
by: Przemek M. Zawada | last post by:
Dear Group, I'm developing sample window form, using DataGridView control, which is filled with data through BindingSource, which is based on type of object, as follow: public sampleClass { public int itemNumber; public string itemName;
2
20237
by: David Jackson | last post by:
Hello, I have an unbound DataGridView of which one of the columns is a ComboBox colum containing category data, plus an additional option called <newSo when the ComboBox is dropped down it looks like this <new> First Second Third
0
1733
by: Dom | last post by:
I have a datagridview control, and one column is a ComboboxColumn. I simply create a ComboboxColumn, add items to it, then add the column to the Datagridview control. If I were working with a simple ComboBox, I could capture an event that fired everytime the selected item changed. Is that possible if the DatagridView control? I've looked at various events, but none give me what I want. For example, the CellEndEdit event won't fire...
0
1388
by: HDI | last post by:
Hi, I'm using vb.net express 2005 and I've got a project where I use a datagridview with a combobox in the first column. Depending on the value the user selects I have to set values of other cells. The problem is that I get the selected value when the datagridview isn't in edit mode. First I have to select another cell.
0
8828
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8677
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7446
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6238
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5704
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.