(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
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?
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.
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
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