c# 4.0 - How to avoid Reload on property set -
public bool showbutton { { return _showbutton; } set { _showbutton = value; reloadgrid(); } } public bool showtext { { return _showtext; } set { _showtext = value; reloadgrid(); } } private void reloadgrid() { gridview.data ...... }
when ever setting 2 proprities need call reloadgrid. requirement if assigned 2 properties reloadgrid should call 1 time happening twice. how avoid ?
how avoid ?
by not calling reloadgrid
in setter of properties.
public bool showbutton { get; set; } public bool showtext { get; set; }
you have call manually:
showbutton = true; showtext = false; reloadgrid();
the other option more difficult. need bool
variable store if it's loaded , have set false
in events data needs refreshed. can check variable in reloadgrid
:
private bool gridneedsreload { get; set; } private void reloadgrid() { if(gridneedsreload) { gridview.data ...... } }
Comments
Post a Comment