iOS picker

Hi. I forget where I found this, but I’ve been using a dtPicker in some of my projects. Getting to work everything just fine. I am using two pickers on my view, populating them on Open, and have a need to swap the contents between the two.

Using this watered down version of this code below in the picker.open events

me.AddColumn(Array("col1","col2","col3"))

Thinking I can just use the same code in a button, but this does not seem to populate. Of course replacing “me” with “picker1” in the code.

Is there a way to remove all columns in a picker and then add in new values in a button.action event?

I’ve never used the dtPicker but for iOSKit everything is managed by a private datasource object is in charge of all of the Picker’s content, so I’m assuming it’s the same since a datasource object is required by Apple.

Thanks Jason. Do you know anyway around this or to be able to accomplish what I’m looking for? Changing the data after the view is initialized?

Figured how to accomplish this. Posting in the event anyone else has a need to alter the pickers at run time.

Picker1.Open

[code] dim tx0() as text

tx0() = Array("", "alcohol gram","carb gram","fat gram","kilocalorie", "kilojoule", "protein gram")

me.AddColumn(tx0)[/code]

Picker2.Open

[code]dim tx0() as text

tx0() = Array("", “kilocalorie”, “kilojoule”)

me.AddColumn(tx0)
[/code]

SwapButton.Action

[code] dtPicker1.RemoveColumn(0)
dtPicker2.RemoveColumn(0)

dim txPick1() as text
dim txPick2() as text

if swapInt = 0 then
txPick1() = Array("", “kilocalorie”, “kilojoule”)
txPick2() = Array("", “alcohol gram”,“carb gram”,“fat gram”,“kilocalorie”, “kilojoule”, “protein gram”)

dtPicker1.AddColumn(txPick1)
dtPicker2.AddColumn(txPick2)

dtPicker1.SelectRow(Picker2Row, Picker2Column)
dtPicker2.SelectRow(Picker1Row, Picker1Column)

Picker1Text = dtPicker1.GetText(Picker2Row, Picker2Column)
Picker2Text = dtPicker2.GetText(Picker1Row, Picker1Column)

swapInt = 1

elseif swapInt = 1 then
txPick1() = Array("", “alcohol gram”,“carb gram”,“fat gram”,“kilocalorie”, “kilojoule”, “protein gram”)
txPick2() = Array("", “kilocalorie”, “kilojoule”)

dtPicker1.AddColumn(txPick1)
dtPicker2.AddColumn(txPick2)

dtPicker1.SelectRow(Picker1Row, Picker1Column)
dtPicker2.SelectRow(Picker2Row, Picker2Column)

Picker1Text = dtPicker1.GetText(Picker1Row, Picker1Column)
Picker2Text = dtPicker2.GetText(Picker2Row, Picker2Column)

swapInt = 0

end if
[/code]