dcsimg
Results 1 to 5 of 5

Thread: (RESOLVED) Adding listbox items to correct Flexgrid rows

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    SF
    Posts
    93

    Question (RESOLVED) Adding listbox items to correct Flexgrid rows

    Hi All,

    Im building a break scheduler.

    I'm trying to populate Flexgrid rows with the employee names. I have 3 columns.


    First Break Lunch Break Last Break <<<< These are the labels for the top row in the columns and they are added using

    .TextMatrix(0, 0) = "FIRST BREAK"
    .TextMatrix(0, 1) = "LUNCH BREAK"
    .TextMatrix(0, 2) = "LAST BREAK"


    the problem that Im facing is that when I add the listbox items (employee names) to any column, the items are added but the first item overwrites and replaces the column label header. So I need to add items starting at row 1. Can anyone help with this?

    Here's my code.

    Dim j as integer

    With MSFlexGrid1

    .TextMatrix(0, 0) = "FIRST BREAK"
    .TextMatrix(0, 1) = "LUNCH BREAK"
    .TextMatrix(0, 2) = "LAST BREAK"

    .Rows = 10

    For j = MSFlexGrid1.Row = -1 To List3.ListCount - 1
    .TextMatrix(j, 0) = List3.List(j)
    Next

    end with


    Thanks,

    Techsent
    Last edited by techsent; Nov 12th, 2013 at 05:40 AM.

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,188

    Re: Adding listbox items to correct Flexgrid rows

    Try:

    Code:
    Dim j as integer
    
     With MSFlexGrid1
    
     .TextMatrix(0, 0) = "FIRST BREAK"
     .TextMatrix(0, 1) = "LUNCH BREAK"
     .TextMatrix(0, 2) = "LAST BREAK"
    
     .Rows = 10
     For j = 1 To List3.ListCount - 1
          list3.listindex = j
          .TextMatrix(j, 0) = list3.text
     Next
    But you realize that all that is doing is putting whatever in list3 into the first column of your grid (First Break), starting in the second (row 1) row...is that what you want?

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,188

    Re: Adding listbox items to correct Flexgrid rows

    AND, you can add rows to your grid one at a time...instead of .Rows = 10,
    put .Rows = .Rows + 1 before the .TextMatrix(j,0) = list3.text line.

  4. #4
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,423

    Re: Adding listbox items to correct Flexgrid rows

    Flex starts at 1 and List starts at 0
    Code:
     For j = 0 To List3.ListCount - 1
        .TextMatrix(j + 1, 0) = List3.List(j)
     Next

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    SF
    Posts
    93

    Re: Adding listbox items to correct Flexgrid rows

    Sam. Yes, I needed to start at the second row so I could maintain the labels in row one. your code worked but it omitted the first employee name. Appreciate the .rows tip, works great.

    Jcis, thanks. works fine.

    Techsent

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width