1

I have a compact framework application [vb.cf] running on windows CE platform. I have a user control that I add multiple times to my to my form , to form a grid, in run-time.

I am now trying to access and set the properties on my user controls and using the ;

Dim mod_prop As ctl_mod_table = CType(Me.pnl_table.Controls("ctr_" & icount), ctl_mod_table)

This produces the following error :

Conversion from string "ctr_1" to type integer is not valid???

Any reason why I get this?

I DO NOT WANT TO USE A LOOP ALL CONTROLS procedure as this is slow.

Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
MackieRSA
  • 39
  • 8

2 Answers2

1

In the Compact Framework you must search the controls by name manually. This SO question has a CF-specific answer.

Community
  • 1
  • 1
ctacke
  • 66,480
  • 18
  • 94
  • 155
0

your Controls(...) is using an index value, so an integer. Here you are trying to pass a string variable, ctr_1, which is obviously... not an integer.

You need to access your control by its name, try simply to call Me.Controls("ctr_" & icount) instead of Me.pnl_table.Controls("ctr_" & icount): you will look at the controls of the form.

Nicolas R
  • 13,812
  • 2
  • 28
  • 57
  • Thanks for this. The reason I use me.pnl_table.controls is because my user controls are inside a panel called pnl_table. Does this makes a difference? – MackieRSA Aug 28 '14 at 11:19
  • his.Controls.Find is not support by cf.net [compact framework]. this is my underlying problem. :( – – MackieRSA Aug 28 '14 at 14:54