Solved

setting the text property of a datagridview combobox column

Posted on 2009-04-04
3
539 Views
Last Modified: 2012-06-27
I am working on a windows application using vb.net. I have a datagrid view on the form..the user can eneter the details in the grid and  submit it....and he can also retrieve the valuse by searching with a specific Field (say ID No)...
so what i want is....how can i set the display  text property of the combobox column ...if that is a textbox, which is not in the datagrid view, i simply would have said

textbox1.Text = abc...
0
Comment
Question by:yuvaratna
3 Comments
 
LVL 18

Expert Comment

by:carlnorrbom
ID: 24071145
Hi,

If you just want to display a certain value it's as simple as:

DataGridView1.Rows(0).Cells("YourColumnName").Value = "Text to display"
0
 

Author Comment

by:yuvaratna
ID: 24072810
i  tried this , but it is throwing an error..Please find the error attached.....

system.argumentexception:DataGridViewcombobox cell value is not valid

I wanted to assign the value in  the database to the respective column of the datagridview, when the user searches for a particular record


Untitled.jpg
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 24073025
I think this is the same problem of other question and this should do:
        For Each row As DataGridViewRow In Me.DataGridView1.Rows

            If Not row.IsNewRow Then

                row.Cells(0).Value = "1"

            End If

        Next

 

        ' Where "1" is the name of the item to select 

Open in new window

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now