marzio
2017-11-21T20:55:00Z
Hallo, thanks for your great product.
I'm having this problem:
I want to insert a value (long type) into a combo cell and I want it to show the text
I wrote a sub Combotipi that fills the combo with cod as value and the related text as text (Example: cod=1, text="car")

when I load the grid If I do it manually, selecting one item, it does correctly show the text (car) and has as value the value of the item (1) , but if I do with a sub (main) that insert a value retrieved from a DB query (long value=1) it shows it as text ("1") instead of showing the text related to the value ("car")


Sub Combotipi
.... reader with data from DB...
combo.Items.Clear()
While reader.Read()
cod = reader.GetValue(0)
combo.Items.Add(cod, reader.GetValue(1))
End While
End Sub

sub main
.Cells(column - 1, 1).DropDownControl = ComboTipi
.... reader2 with data from DB...
.Cells(column - 1, 1).Value = reader2.GetValue(column - 1)
...

I tried many variations (auxvalue, notext ecc) but none worked
thanks
Igor/10Tec
2017-11-23T14:41:25Z
It's hard to say what can be wrong without having a live sample. Can you prepare and send us a project that demonstrates the problem?

If it's not possible, the only idea that came into my mind is to try to use native data types instead of objects returned by the IDataReader.GetValue() method. Try to use IDataReader.GetInt32() instead and tell us the result.

Try also this in Sub Main()

.Cells(column - 1, 1).Value = 1

and tell us whether the combo item is found properly.
marzio
2017-11-24T07:41:32Z
Dear Igor I forgot to write that I already tried to set manually a value to the cells.value (=1) and instead of showing the item list it shows me "1"
Igor/10Tec
2017-11-24T12:14:36Z
May I expect to see a sample that demonstrates the problem?

Have you tried what I wrote with IDataReader.GetInt32()? You need to use it everywhere - when you populate the combo list and cell values.

BTW, you can also try to use the FillWithData method instead of your code that populates iGrid. FillWithData "knows" that cells in columns can be combo cells.
marzio
2017-11-25T21:23:01Z
Dear Igor, this is the code updated with fillwithdata:

cmd.Connection = connTemp
cmd.CommandText = stringaSQL
combo.Items.Clear()
combo.FillWithData(cmd, FieldNameForLong, FieldNameForText)


this is the code where I insert the value (Long) into the cell with the combo :

.Cells(column - 1, 1).Value = reader.GetValue(column - 1)

I even tried .getInt32(column-1) but it still shows me the numeric value instead of the text

Immagine.bmp

Click to View Image65 View(s)

marzio
2017-11-25T21:40:32Z
Just to add some more infos:
I retrieve the data from an ACCESS DB and the field to fill the combo values is a counter (long) while the field to set the value in order to show the text is a Long
both are DBTYPE_I4
marzio
2017-11-25T21:46:45Z
I just resolved converting values inserted with .tostring
so now basically all the values of the combos are string and not any more numeric (probably in this way it affects loading times)