CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Join Date
    Dec 2002
    Location
    Tenby, Wales
    Posts
    277

    Re: DataGridViewComboBox problem!

    Did anyone manage to take a look? I agree that the code is fine - tried it in another databound Datagrid of mine and it worked fine.

    There's gotta be something preventing it either in the designer or in code!
    Visual Basic 2005 ver. 8.0.50727.867

  2. #17
    Join Date
    Dec 2002
    Location
    Tenby, Wales
    Posts
    277

    Re: DataGridViewComboBox problem!

    I have sorted it. All I did was change the Property Readonly from True to False in the Datagridview designer and now it works!

    Surely that shouldn't have been affecting the ComboBoxColumn??
    Visual Basic 2005 ver. 8.0.50727.867

  3. #18
    Join Date
    Aug 2005
    Location
    Imperial College London, England
    Posts
    490

    Re: DataGridViewComboBox problem!

    That kind of makes sense - if the entire grid is read-only, then you won't be allowed to change the value of the combo, so it won't drop down.
    Help from me is always guaranteed!*
    VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
    Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.

    *Guarantee may not be honoured.

  4. #19
    Join Date
    Dec 2002
    Location
    Tenby, Wales
    Posts
    277

    Re: DataGridViewComboBox problem!

    It's doing something else strange now - when I click save it says that:
    Parameter @7 has no default value
    This is the column I was having trouble with before. I have tried both selecting values for each row in the column and also setting:
    Code:
    .DefaultCellStyle.NullValue = "0"
    but it still comes up with that error. I have also tried:
    Code:
    DataGridView1.CommitEdit
    but still nothing!
    Visual Basic 2005 ver. 8.0.50727.867

  5. #20
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: DataGridViewComboBox problem!

    LOL! It is always the small things that mean big headaches!
    I knew it had to be something else

    I just run your app now ( only started with it now ), and I got a Parameter @13 has no default value, in this section :
    Code:
     If ExcelYear = "10" Then
                                Dim MyExcelConnection As New System.Data.OleDb.OleDbConnection _
                                ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\08-09\Year 10 2008-09.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=0""")
                                MyExcelConnection.Open()
                                With myInsertCommand
                                    .CommandText = "Insert INTO [Sheet1$] ([StudentId],[StudentName],[ClassGrp],[TheDate],[Merits],[Demerits],[Penalty],[Lesson]," + _
                                            "[TeachingGrp],[Staff],[Description],[Action],[MeritType]) VALUES(@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11,@12,@13)"
                                    .CommandType = CommandType.Text
                                    .Connection = MyExcelConnection
                                    For Each Row As DataGridViewRow In DataGridView1.Rows
                                        For Col As Int32 = 1 To Row.Cells.Count
                                            .Parameters.Add(New OleDb.OleDbParameter("@" & Col, OleDb.OleDbType.Char)).Value = CStr(Row.Cells(Col - 1).Value)
                                        Next Col
                                        .ExecuteNonQuery()
                                        .Parameters.Clear()
                                    Next
                                End With
    Parameter 13 in this case is Merits

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured