Change Property Dinamically

  • Thread starter Thread starter srcp
  • Start date Start date
S

srcp

I got a table with for example 10 fields, field001, field002 ...field010

what i want is do something like this

For i As Integer = 1 To 10
(table.field00 & i).value = "XX"
Next i

any ideas??
 
srcp.

What do you mean with a table is that something to eat from.

As it is a datarow then it is simple

for i = 0 to 9
datarow.item(i) = "XX"
next

Assumming all fields are strings

Giving some more information mostly give better answers.

Cor
 
I got a table with for example 10 fields, field001, field002 ...field010

what i want is do something like this

For i As Integer = 1 To 10
         (table.field00 & i).value = "XX"
Next i

any ideas??

I'm not really sure what you're trying to accomplish here, but if it's
what I think than you need to read up on Reflection,
Type.GetProperties, PropertyInfo, and PropertyInfo.SetValue.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
srcp said:
I got a table with for example 10 fields, field001, field002 ...field010
what i want is do something like this
For i As Integer = 1 To 10
(table.field00 & i).value = "XX"

If we're talking DataTables here, then they don't have Fields; DataRows
/within/ a Datatable do. In that case, you could so something like this:

Dim dr as DataRow = ...

For i As Integer = 1 To 10

Dim sFieldName as String _
= String.Format( "Field{0:000}", i )

dr.Item( sFieldName ) = "XX"
Next

HTH,
Phill W.
 
Thanks Cor, being more acurate in what i'm trying to do:

' Create a proxy from SAP
Public Proxy As new SAPProxy(dtSap.ConnectionString)

Dim myR3Table as New ZtestTable

Proxy.Connection.Open()

'I've already importe a function that fill a table defined in SAP

Proxy.zhr_rfc_fillTable(myR3Table)

By doing this i fill the table myR3Table, this is only a structure defined
in SAP system.



Thanks for your Help.

Sergio.
 
Thanks Seth, what i'm trying to do is changing a property for a set of
objects (in this case a row of a sap r3 table, but it can be a textbox,
button, etc) but doing it in just one line, i mean creating the name of the
object in runtime.


I got a table with for example 10 fields, field001, field002 ...field010

what i want is do something like this

For i As Integer = 1 To 10
(table.field00 & i).value = "XX"
Next i

any ideas??

I'm not really sure what you're trying to accomplish here, but if it's
what I think than you need to read up on Reflection,
Type.GetProperties, PropertyInfo, and PropertyInfo.SetValue.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
Back
Top