Results 1 to 3 of 3

Thread: combo box and msflexgrid

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Location
    Calgary,Alberta, Canada
    Posts
    70

    Post

    i new to vb and trying to figure a way to remove the text from the combobox and put it into the flexgrid at the same time but when i select text in the middle of the list box it will transfer to the grid but will not remove the text from the combo box . here's what i have for code this create a error message when i try to add 5 or 6 items to the grid i would like to know how to also store the text from the combo box to a variable
    thxs anyone Private Sub Form_Load()
    Create_Movie_List
    Form_Refresh
    End Sub




    'loads moviedata to cbomovies
    Private Sub Create_Movie_List()
    Dim strTemp As String
    Dim intCount As Integer
    Dim intFreeFile As Integer
    Dim intInstr As Integer

    intCount = 0
    intFreeFile = FreeFile

    Open MovieData For Input As #intFreeFile

    Do
    ReDim Preserve S_TagMovieFile(intCount)

    Input #intFreeFile, strTemp
    intInstr = InStr(strTemp, "|")
    S_TagMovieFile(intCount).strMovieName = Left(strTemp, intInstr - 1)
    S_TagMovieFile(intCount).dblPrice = Right(strTemp, Len(strTemp) - (intInstr))

    cboMovies.AddItem S_TagMovieFile(intCount).strMovieName
    intCount = intCount + 1
    Loop Until EOF(intFreeFile)
    Close #intFreeFile

    End Sub
    Private Sub Form_Refresh()
    Create_Grid
    End Sub

    Private Sub cmdAddMovie_Click()
    If cboMovies.Text = "" Then Exit Sub

    grdMovieselect.Col = 1
    grdMovieselect.Row = intMovieCount + 1
    grdMovieselect.Text = cboMovies.Text
    intMovieCount = intMovieCount + 1
    grdMovieselect.Rows = intMovieCount + 2

    Fill_Movie_grid

    End Sub
    Private Sub Create_Grid()


    grdMovieselect.Rows = 2
    grdMovieselect.Cols = 3

    grdMovieselect.ColWidth(0) = 5

    grdMovieselect.Row = 0
    grdMovieselect.Col = 1
    grdMovieselect.ColWidth(1) = 1500
    grdMovieselect.Text = " Movie Name"


    grdMovieselect.Row = 0
    grdMovieselect.Col = 2
    grdMovieselect.ColWidth(2) = 700
    grdMovieselect.Text = " Cost"


    End Sub
    Private Sub Fill_Movie_grid()
    Dim iIndex As Integer

    ReDim S_TagMovieFile(0)
    With FormVideo
    For iIndex = 0 To intMovieCount - 1
    ReDim Preserve S_TagMovieFile(iIndex)

    .grdMovieselect.Row = iIndex + 1
    .grdMovieselect.Col = 1
    S_TagMovieFile(iIndex).strMovieName = .grdMovieselect.Text
    cboMovies.Text = cboMovies.RemoveItem(iIndex)
    Next iIndex

    End With

    End Sub

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    I don't understand what it is you're asking, but there is alot you can do to make your life easier when using a FlexGrid Control, for example, you can load text into any Cell using the TextMatrix Method, which allows you to specify the Row and Col, plus you can add an entire row to the Gird in one go, eg. grdMovies.AddItem "Column1" & Chr(9) & "Column2" & Chr(9) & "Etc..".
    Code:
    Private Sub Form_Load()
        Create_Grid
        Create_Movie_List
    End Sub
    
    Private Sub Create_Movie_List()
        Dim iFile As Integer
        Dim sData As String
        
        iFile = FreeFile
        
        Open "C:\Movies.txt" For Input As iFile
        grdMovies.Rows = 1
        While Not EOF(iFile)
            Input #iFile, sData
            grdMovies.AddItem Replace(sData, "|", Chr(9))
        Wend
        Close iFile
    
    End Sub
    
    Private Sub cmdAddMovie_Click()
        If Len(Text1) = 0 Then Exit Sub
        grdMovies.AddItem Text1 & Chr(9) & Text2
    End Sub
    
    Private Sub Create_Grid()
        With grdMovies
            .Rows = 2
            .Cols = 2
            .FixedCols = 0
            .FixedRows = 1
            .ColWidth(0) = 1500
            .ColWidth(1) = 700
            .TextMatrix(0, 0) = " Movie Name"
            .TextMatrix(0, 1) = " Cost"
        End With
    End Sub
    If you need further assistance, please be a little more specifc and clearer.

    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Location
    Calgary,Alberta, Canada
    Posts
    70

    Post

    Thanks for your help hmm i should of reread my question and worded it properly

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