Solved

setting the text property of a datagridview combobox column

Posted on 2009-04-04
3
563 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

820 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