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

Select an item from DataGridViewComboboxCell

I have a DataGridView in which one of its columns is a DatagridViewCombobox. This column contains values as
1. "ROAMING"
2. "MOBILE"
3. "TELEPHONY"...

I want to select an index from this DatagridViewComboboxCell programmatically, for example 2 ("MOBILE").

Is anyone knows an easy way of doing this.

Thak you
Jul 21 '06 #1
2 8804
I have a DataGridView in which one of its columns is a DatagridViewCombobox. This column contains values as
1. "ROAMING"
2. "MOBILE"
3. "TELEPHONY"...

I want to select an index from this DatagridViewComboboxCell programmatically, for example 2 ("MOBILE").

Is anyone knows an easy way of doing this.

Thak you
Hi hope this will give you some idea

<asp:DropDownList id="methdselect" runat="server" datasource='<%# Methodlist.items %>' SelectedIndex='<%#GetStateIndex(DataBinder.Eval(Co ntainer, "DataItem.Method")) %>'></asp:DropDownList>

Protected Function GetStateIndex(ByVal Method As String) As Integer
dim i As Integer = Methodlist.Items.IndexOf(Methodlist.Items.FindByTe xt(Method))
Return i
End Function

Where Methodlist is arraylist of all the methods you have included in the comboxbox i used to bind the same arraylist with comobox

Regards
Jul 21 '06 #2
Thank you for the reply

I am writing an application form and not an asp.
The values of the DataGridViewComboboxCell are retrieved from a database table (dataset).

e.g.
CType(DataGV1.Columns(1), DataGridViewComboBoxColumn).DataSource = DataSet1
CType(DataGV1.Columns(1),DataGridViewComboBoxColum n).DisplayMember = "Table2.PRODUCT_CON_DESCRIPTION"
CType(DataGV1.Columns(1), DataGridViewComboBoxColumn).ValueMember = "Table2.PRODUCT_CON_ID"

I am trying to select an item in a specific Cell of this Datagrid. So even though I can find the index of the value I cannot find a method to set the new selectedIndex.
I am confused.
Jul 24 '06 #3

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

Similar topics

0
by: Moshazu | last post by:
I am attempting to use the DataGridView control in my software and have not been able to easily find answers to a couple of questions that I have. 1. Is the only way to change the data in a...
0
by: Jay | last post by:
I am using Windows .Net 2.0 SDK I have a DataGridView control in a windows form. None of my controls are databound prior to run time. I am creating a string array with which I want to populate...
2
by: Andrew Lias | last post by:
Let us say that I have a table with two sets of values as such: Item Extension --- ---- 100023 1 100025 1 100025 2 100028 1 100029 1 100029 2
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
0
by: Bruno Neves Pires Silva | last post by:
Hello, everybody. How can I get the selected item index in a DataGridViewComboBoxCell, in a datagridview?
0
by: news.microsoft.com | last post by:
Hello- I'm having a dickens of a time trying to set the value on a DataGridViewComboBoxColumn. I actually have two DataGridViewComboBoxColumns in my datagrid view. First, I'm setting up the...
0
by: =?Utf-8?B?R2FkeUM=?= | last post by:
HI I populate one col. in a dataiewgrid with a combocell as DataGridViewComboBoxCell. (create on the fly and assign it to cell) I need to avid arrow user's up/down on that cells. All the grid...
1
by: JB | last post by:
Hi All, Is there a way to programmatically open the drop down list of a DataGridViewComboBoxCell? Thanks JB
4
by: Martin Horst | last post by:
Hi, I've got a Windows Form DataGridView with several DataGridViewComboBoxCell columns. The Items collection of the DataGridViewComboBoxCell can take any kind of objects. But when the user...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.