c# - Refreshing DataGridView? -
i provide "refresh" button on form containing datagridview object bound mysql database. have gotten screens without columns populated query calculated fields "new"ing mysqlcommand, mysqldataadapter, mysqlcommandbuilder , dataset objects , rerunning query , reloading binding source datagridview object.
for ones have calculated columns, not work.
surely, there must way have datagridview object reload db.
i using sharpdevelop c# 5 .net framework 4.0, mysql community server 5.3.33 , mysql data connector/.net v 6.7.4
any leads appreciated!
jesse , brian,
i doing winforms - sorry not being clear. have worked out solution. first, executing run in initial load not enough. found 1 must "new" mysqlcommand, mysqldataadapter, mysqlcommandbuilder , dataset objects, run data fetch in form load. also, cannot called while doing looks or smells "editing" or throw exception. wanted form refresh after edit, put timer on form , enabled @ end of rowvalidated event , let timer call reloadgrid routine. also, if user on, row 822, found focus went row 0 , cell 0, save current row , cell point , set focus after data refresh.
private void bindgrid(){ //retrieve data //bind datagridview.datasource = datasource; datagridview.databind(); } //call bindgrid() anytime need refresh data, example in button event click handler
Comments
Post a Comment