SirBavol
2017-10-31T07:13:03Z
Using a licensed version of 6.5 igrid, not sure if the demo version is different then the Licensed version.
never played much with the demo version, but love the version i have, so many things to make my code to look and be so much better!

I have the list for the combo box loading ok, shows the list just like its suppose to...

CheckGrid.Combos.Clear
With CheckGrid
With .Combos.Add("FirstRow")
Do Until tbl_Chk_Account_oRS.EOF
.AddItem tbl_Chk_Account_oRS("cDept_name"), tbl_Chk_Account_oRS("lAcc_id")
tbl_Chk_Account_oRS.MoveNext
Loop
End With
.CellType(1, 1) = igCellCombo
.CellCtrlKey(1, 1) = "FirstRow"
End With

and when i click on one of the items it shows in the box and sets the .cellvalue(1, 1) correctly
BUT what i can not figure out how to do...is if i set the .cellvalue(1, 1) using code
I would like the box to auto show the text in the box that matchs the value I set.
Like vb comboboxes, if you set the listindex in the code, the combobox show the right text that matches
the listindex you gave it in the vb code.

EX: when i click on the combo box and say click Grocery, it sets the .cellvalue to 2
what i want to do is set the .cellvalue to 2 and when the list loads, it shows Grocery, not blank.

its is setting the .cellvalue of the "lAcc_id" like i want it to. So Grocery's lacc_id is 2. SO when I set the
.cellvalue from the code, I would like it to read the lAcc_id and show the Text matching that.

Any help would be awesome. Thanks in advance.
Igor/10Tec
2017-10-31T07:47:35Z
iGrid must display the corresponding combo list item text when you change the cell value. Can you send us a sample that demonstrates this problem?
SirBavol
2017-10-31T08:11:02Z
I have images, but not as URLs
Let me try and give you the code, that might help...

loading the grid...

With CheckGrid
.BeginUpdate

.Font.Size = 12
.Gridlines = igGridLinesBoth

' .GridlineColor = RGB(255, 192, 255)

.ColCount = 0
.RowCount = 0

.AddCol(sHeader:="ACCOUNT", lWidth:=315, eheaderalignh:=igAlignHCenter).eAlignH = igAlignHLeft
.AddCol(sHeader:="AMOUNT", lWidth:=160, eheaderalignh:=igAlignHCenter).eAlignH = igAlignHRight
.AddCol(sHeader:="INVOICE NUMBER", lWidth:=315, eheaderalignh:=igAlignHCenter).eAlignH = igAlignHCenter

.Header.Visible = True
.Header.Buttons = False
.Header.Font.Bold = True
.DefaultRowHeight = .GetOptimalCellHeight()

.AddRow
.CellFmtString(.RowCount, 2) = "#,##0.00"
.AddRow
.CellFmtString(.RowCount, 2) = "#,##0.00"
.AddRow
.CellFmtString(.RowCount, 2) = "#,##0.00"
.AddRow
.CellFmtString(.RowCount, 2) = "#,##0.00"
.AddRow
.CellFmtString(.RowCount, 2) = "#,##0.00"
.AddRow
.CellFmtString(.RowCount, 2) = "#,##0.00"

For I = 1 To 6
.CellValue(I, 1) = "2"
.CellValue(I, 2) = "0"
Next

.BackColorEvenRows = RGB(203, 255, 203)

.EndUpdate
End With

then i load the combo boxs

strSQL = "SELECT * "
strSQL = strSQL & "FROM tblAccountTypes "
strSQL = strSQL & "ORDER by cDept_name ASC"

Set tbl_Chk_Account_oRS = New Recordset

tbl_Chk_Account_oRS.Open strSQL, goConnCB, _
adOpenForwardOnly, adLockReadOnly

CheckGrid.Combos.Clear
With CheckGrid
With .Combos.Add("FirstRow")
Do Until tbl_Chk_Account_oRS.EOF
.AddItem tbl_Chk_Account_oRS("cDept_name"), tbl_Chk_Account_oRS("lAcc_id")
tbl_Chk_Account_oRS.MoveNext
Loop
End With
.CellType(1, 1) = igCellCombo
.CellCtrlKey(1, 1) = "FirstRow"
.CellValue(1, 1) = "2"
End With
tbl_Chk_Account_oRS.MoveFirst
With CheckGrid
With .Combos.Add("SecondRow")
Do Until tbl_Chk_Account_oRS.EOF
.AddItem tbl_Chk_Account_oRS("cDept_name"), tbl_Chk_Account_oRS("lAcc_id")
tbl_Chk_Account_oRS.MoveNext
Loop
End With
.CellType(2, 1) = igCellCombo
.CellCtrlKey(2, 1) = "SecondRow"
End With
tbl_Chk_Account_oRS.MoveFirst
With CheckGrid
With .Combos.Add("ThirdRow")
Do Until tbl_Chk_Account_oRS.EOF
.AddItem tbl_Chk_Account_oRS("cDept_name"), tbl_Chk_Account_oRS("lAcc_id")
tbl_Chk_Account_oRS.MoveNext
Loop
End With
.CellType(3, 1) = igCellCombo
.CellCtrlKey(3, 1) = "ThirdRow"
End With
tbl_Chk_Account_oRS.MoveFirst
With CheckGrid
With .Combos.Add("ForthRow")
Do Until tbl_Chk_Account_oRS.EOF
.AddItem tbl_Chk_Account_oRS("cDept_name"), tbl_Chk_Account_oRS("lAcc_id")
tbl_Chk_Account_oRS.MoveNext
Loop
End With
.CellType(4, 1) = igCellCombo
.CellCtrlKey(4, 1) = "ForthRow"
End With
tbl_Chk_Account_oRS.MoveFirst
With CheckGrid
With .Combos.Add("FifthRow")
Do Until tbl_Chk_Account_oRS.EOF
.AddItem tbl_Chk_Account_oRS("cDept_name"), tbl_Chk_Account_oRS("lAcc_id")
tbl_Chk_Account_oRS.MoveNext
Loop
End With
.CellType(5, 1) = igCellCombo
.CellCtrlKey(5, 1) = "FifthRow"
End With
tbl_Chk_Account_oRS.MoveFirst
With CheckGrid
With .Combos.Add("SixthRow")
Do Until tbl_Chk_Account_oRS.EOF
.AddItem tbl_Chk_Account_oRS("cDept_name"), tbl_Chk_Account_oRS("lAcc_id")
tbl_Chk_Account_oRS.MoveNext
Loop
End With
.CellType(6, 1) = igCellCombo
.CellCtrlKey(6, 1) = "SixthRow"
End With
tbl_Chk_Account_oRS.Close
CheckGrid.ShowControlsInAllCells = True

when I load the program, it makes all the combos and lets me using them right. and if i click on one and click on an item in the list
it changes the .cellvalue to the right number.
But as you can see by the ones that i have underlined, i am trying to get it to show the Second Item in the list when it loads...in this case
the word "Grocery"
it sets the .cellvalue to 2 changing the -1 setting, but still shows blank in the box. like its still set to -1
and if i click on the box, and click Grocery, it then shows up and sets the .cellvalue to 2 again. Im at a loss...
Igor/10Tec
2017-10-31T15:19:25Z
I guess the problem is in the following code:

With .Combos.Add("FirstRow")
   Do Until tbl_Chk_Account_oRS.EOF
      .AddItem tbl_Chk_Account_oRS("cDept_name"), tbl_Chk_Account_oRS("lAcc_id")
      tbl_Chk_Account_oRS.MoveNext
   Loop
End With

When you write an expression like tbl_Chk_Account_oRS("lAcc_id"), in fact you reference the whole ADODB.Field object. Yes, its default property is Value returning the value of the field, but in this case you reference the ADODB.Field object stored instead of the value. To fix the problem, try to use the following modification of the AddItem call:

.AddItem tbl_Chk_Account_oRS("cDept_name").Value, tbl_Chk_Account_oRS("lAcc_id").Value

*******************************************************

Two ideas how to simplify your code.

First, the iGrid ComboObject also provides you with the FillFromRS method starting with the v6.5. Having this, the above code block can be replaced with the following call:

.Combos.Add("FirstRow").FillFromRS tbl_Chk_Account_oRS, "cDept_name", "lAcc_id"

Second, the following code block

.AddRow
.CellFmtString(.RowCount, 2) = "#,##0.00"
.AddRow
.CellFmtString(.RowCount, 2) = "#,##0.00"
.AddRow
.CellFmtString(.RowCount, 2) = "#,##0.00"
.AddRow
.CellFmtString(.RowCount, 2) = "#,##0.00"
.AddRow
.CellFmtString(.RowCount, 2) = "#,##0.00"
.AddRow
.CellFmtString(.RowCount, 2) = "#,##0.00"

can be simplified using the default column cell:

.ColDefaultCell(2).sFmtString = "#,##0.00"
.RowCount = 6


Quote:

I have images, but not as URLs



This forum contains a step-by-step instruction how to upload images to your posts:

Upload images to this forum 
SirBavol
2017-10-31T16:30:11Z
Thank you for the code suggestions, made the code so much smaller!

ok now it looks like this

CheckGrid.Combos.Clear
With CheckGrid
.Combos.Add("FirstRow").FillFromRS tbl_Chk_Account_oRS, "cDept_name", "lAcc_id"
.CellType(1, 1) = igCellCombo
.CellCtrlKey(1, 1) = "FirstRow"
.CellValue(1, 1) = "2"
.Combos.Add("SecondRow").FillFromRS tbl_Chk_Account_oRS, "cDept_name", "lAcc_id"
.CellType(2, 1) = igCellCombo
.CellCtrlKey(2, 1) = "SecondRow"
.Combos.Add("ThirdRow").FillFromRS tbl_Chk_Account_oRS, "cDept_name", "lAcc_id"
.CellType(3, 1) = igCellCombo
.CellCtrlKey(3, 1) = "ThirdRow"
.Combos.Add("ForthRow").FillFromRS tbl_Chk_Account_oRS, "cDept_name", "lAcc_id"
.CellType(4, 1) = igCellCombo
.CellCtrlKey(4, 1) = "ForthRow"
.Combos.Add("FifthRow").FillFromRS tbl_Chk_Account_oRS, "cDept_name", "lAcc_id"
.CellType(5, 1) = igCellCombo
.CellCtrlKey(5, 1) = "FifthRow"
.Combos.Add("SixthRow").FillFromRS tbl_Chk_Account_oRS, "cDept_name", "lAcc_id"
.CellType(6, 1) = igCellCombo
.CellCtrlKey(6, 1) = "SixthRow"
End With
tbl_Chk_Account_oRS.Close
CheckGrid.ShowControlsInAllCells = True

as you can see i set .cellvalue(1, 1) = 2 for the FirstRow .combos.add

on this image it shows them all loaded, perfect.
Image1.jpg

Click to View Image34 View(s)



This image shows them all in there and if i click on one of them it puts it in the box to see
Image2.jpg

Click to View Image31 View(s)



like this
Image4.jpg

Click to View Image30 View(s)



this is what it looks like when i use the .cellvalue set to 2 in the first combobox, I want it to show the listing like it does when i click on it.
Image1.jpg

Click to View Image34 View(s)



I was hoping to make it look like this when it loads it from the code so it shows up like this as the default
Image4.jpg

Click to View Image30 View(s)


with out them having to have clicked on it.

Thank you for taking the time to work on this. JAnd the quick responses, this is an awesome learning experience for me

Igor/10Tec
2017-10-31T16:51:58Z
Is there a difference between

.CellValue(1, 1) = "2"

and

.CellValue(1, 1) = 2

?

Looking at the filed names used as the combo item values, I think you use numeric IDs. Thus, you need to assign numeric values to CellValue to make it work.
SirBavol
2017-10-31T17:01:46Z
Yes there is, with out the "" it worked perfect!!!!!!!!!!!!!
THANK YOU SO MUCH!

Now if you could make it so the mouse scroll wheel works in the combobox you will be my HERO!!!!!
Igor/10Tec
2017-11-01T12:54:15Z
iGrid''s drop-down lists are based on the native Windows combo box functionality that supports mouse wheel scrolling out-of-the-box. Just in case, I have just tested combo box cells from the latest release of iGrid (6.5.80) with 3 mices I found in the Office from different vendors (Logitech, Trust, Rapoo). All they can be used to scroll the combo list contents using the mouse wheel.

From my experience I can tell that not all mices send the proper Windows messages to scroll the contents. Perhaps, this is the reason why your mouse can't be used for that. Try to use another mouse and tell us whether its wheel scrolls iGrid drop-down lists.

If possible, please, let's discuss this in another new thread with the subject corresponding to the problem. The subject of this thread is not relevant to the problem you touched.