vb.net - Binding a custom property to a datatable field ,the source table is changing when navigating through items -


i've got custom control inherited textbox added custom property follows

dim _myval object public property myval object             return _myval     end     set(value object)         _myval = value         if isnothing(value) orelse isdbnull(value)             me.text = "null"         else             select case _myval                 case 1                     me.text = "newyork"                 case 2                     me.text = "london"                 case 3                     me.text = "zwara"                 case else                     me.text = "unknown"             end select         end if     end set end property 

so bound property datatable field in simple winform datagridview , custom textbox follows

public class form10  dim dtmain new datatable dim bsmain new bindingsource  private sub form10_load(sender system.object, e system.eventargs) handles mybase.load      dtmain.columns.add("name", gettype(string))     dtmain.columns.add("cityid", gettype(integer))      dtmain.rows.add("john", 1)     dtmain.rows.add("steve", 2)     dtmain.rows.add("sara", 3)     dtmain.rows.add("joe", dbnull.value)      bsmain.datasource = dtmain     dgv.datasource = bsmain      txtcity.databindings.add(new system.windows.forms.binding("myval", bsmain, "cityid", false, datasourceupdatemode.onpropertychanged))      dtmain.acceptchanges() end sub 

my problems is, when navigate through items, datatable changed. why happen?

while when bind field combobox selectedvalue property works perfectly. doesn't change source through navigating; changes when change selectedvalue property


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -