473,320 Members | 1,694 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,320 software developers and data experts.

C# windows Assign a value to DataGridViewComboBox cell based on another row

Plater
7,872 Expert 4TB
I feel like this question has been asked before, but I couldn't find it.
I think I am missing something obvious.

Basically I am going to have a DataGridView with two columns. One textbox, one combobox.
The textbox column is going to be coming from a database (actually I could manually create it if i had to). It makes about 20 rows, each with a unique value for the textbox column.
The available choices for the combobox row are coming from a list (I apply it as a datasource currently, it might be better if I manually add the items?)

So for each entry, you can pick a value from a combox, pretty simple, that part works.

Now what I want is, based on some criteria, that a certain value in the combobox field be "selected" by start, instead of an empty box.

I am roughly going to take a particular string, and if its a choice in the combobox, select it. If it is NOT a choice, select the first item in the combobox.

I cannot seem to set the combobox value. With a regular combobox, there is a .Contains on the items (items is always empty when using a datasource) and then is has a .SelectedItem property. The Selected whatever properties aren't on thse DataGridViewComboBox cells.

I have tried just setting the .Value property of the cell, which correctly triggers the DataError event if it's not a choice, but then the value cannot be re-set based on that?


EDIT: I attached a picture of desired output. I can correctly set the values (using the Items.Contains()) now, but it only actually sets the value if I have "looked" at the DataGridView first (its on another tab)
Attached Images
File Type: jpg desiredlayout.JPG (14.5 KB, 497 views)
Oct 30 '08 #1
1 4493
Plater
7,872 Expert 4TB
What I ended up doing was putting it all on the main tab...and hoping it doesn't cause anymore issues
Oct 31 '08 #2

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

Similar topics

1
by: Dominik Luyten | last post by:
Hi, I would like to format certain DataRows in a Windows.Forms.DataGrid. I know how to do that for the columns, but I cannot find a way to assign a specific font, color etc. to a specific kind...
3
by: Richard | last post by:
I'm trying to change a value of a cell based on another before the grid is displayed. I'm using the ItemDataBound event like this for a simple test: Select Case e.Item.ItemType Case...
3
by: Chris Paul | last post by:
I'm having trouble with PHP & PostgreSQL/OpenLDAP/Apache on Windows. I've set this up countless times on BSD (piece of cake) but I'm trying to do this on Windows now so that my developer can work...
6
by: Andrew Robinson | last post by:
assuming that I have a class public class MyClass { public string FirstName { get {...} set {...} } } how can I assign the FirstName property using reflection on a generic class
0
by: alwayssmiling | last post by:
Hi All, In my class im reading each and every cell with the help of indexes like .... . From this im reading the Color value of that cell. Now i want to assign this color value to some...
5
by: Ronald S. Cook | last post by:
I need ideas on how to best design a Windows form for my particular situation. On a cattle feeding yard there will be between about 300 and 600 pens. On my "Pen Feeding Sequence" form, I want...
5
by: howa | last post by:
Hi, Consider a simple example, e.g. var a = { 'a': 'b', 'c': 'd' }
0
by: dan | last post by:
Hi, I have a GridView with five columns. One of the column renders its content either as a FileUpload or TextBox - depending on a value in another cell. I created an EditItemTemplate for the...
2
by: =?Utf-8?B?RHJEQkY=?= | last post by:
I understand that the Value put into a DataGridViewComboBoxCell has to be a member of the Items list or an exception is thrown. I also understand that you can override that exception by handling...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.