Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2006

Tip: Looking for answers? Try searching our database.

DataGridViewComboBoxColumn problems when manually creating view

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ReinierG - 06 Mar 2006 11:21 GMT
When using a datagridview, which contains one DataGridViewComboBoxColumn, I
get an error (System.FormatException: DataGridViewComboBoxCell value is not
valid), which has something to do with the databinding.

Situation:
I create a tabledef:
Dim dt As DataTable
dt = New DataTable(TABELDISPLAY)
dt.Columns.Add("CostplanID", GetType(Long))
dt.Columns.Add("CosttypeID", GetType(Long))
gDatasetDisplay.Tables.Add(dt)

I fill it:
 For Each MyRow As DataRow In gdbProject.Costplan.GetRows()
   dr = gDatasetDisplay.Tables(TABELDISPLAY).NewRow()
   dr("CostplanID") =  gdbProject.Costplan.CostplanID(MyRow)
   dr("CosttypeID") =  gdbProject.Costplan.GetCosttypeID(CostplanID)
   gDatasetDisplay.Tables(TABELDISPLAY).Rows.Add(dr)
 Next
 MyDataView = New DataView(gDatasetDisplay.Tables(TABELDISPLAY), "", "",
DataViewRowState.CurrentRows) '"[MilestoneID]=" & MilestoneID & " AND
[PartnerID]=" & PartnerID
 MyDataGridView.DataSource = MyDataView

I add a combo to the list, which should be linked to CosttypeID
 Dim List As New DataGridViewComboBoxColumn()
 List.HeaderText = "Costtype"
 List.DataPropertyName = "CosttypeID"
 DBProgram.Costtype.GetCosttypes(List)
 .Columns.Add(List)

This however does not seem to work. What am I doing wrong???

The odd thing however, If I use the following code (which I do not WANT to
use), it shows the combobox without the error!:

 gDatasetDisplay = New DataSet
 Dim MyDBLink As New DBLink(DBProgram.GetConnectionString, QUERYDISPLAY,  
TABELDISPLAY)
 MyDBLink.OpenRecordset(gDatasetDisplay)
 MyDBLink.Dispose()
 MyDataView = New DataView(gDatasetDisplay.Tables(TABELDISPLAY), "", "",
DataViewRowState.CurrentRows) '"[MilestoneID]=" & MilestoneID & " AND
[PartnerID]=" & PartnerID
 MyDataGridView.DataSource = MyDataView
ReinierG - 06 Mar 2006 12:00 GMT
Just some more info:

If I disable the error warning, and run the program, I get a datagridview
with in the combobox the values of the costtypeID. When I press the dropdown,
it shows me the names of the costtypes. If I unbind the column, it shows the
costtypes all the time (but this is not what I need).

The combobox datasource is:
 Public Function GetCosttypes(ByRef MyCombobox As  
DataGridViewComboBoxColumn) As Boolean
   MyCombobox.DisplayMember = "Costtype"
   MyCombobox.ValueMember = "CosttypeID"
   MyCombobox.DataSource = GetDataView()
   Return True
 End Function

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.