i have tabcontrol contains datagridview , toolstripbutton. datagridview has multiple select enabled. function of toolstripbutton delete rows datagridview.
the datagridview has bindingsource:
partial class myview { ... this.mybindingsource = new system.windows.forms.bindingsource(this.components); ... this.datagridview.datasource = this.mybindingsource; this.datagridview.selectionmode = system.windows.forms.datagridviewselectionmode.fullrowselect; this.datagridview.multiselect = true; .... this.tsbdelete.click += new system.eventhandler(this.tsbdelete_click); ... i have event handler delete button so:
public partial class myview : system.windows.forms.usercontrol, imyview { ... private void tsbdelete_click (object sender, system.eventargs e) { var current = mybindingsource.current; ... } current single selection. if multiple rows have been selected, last selected. can't figure out how rows selected. difficulty datagridview not available in event handler (or don't know how access , problem). if could, access datagridview.selectedrows. sender button, not directly connected datagridview.
how do this?
fully specified:
system.windows.forms.tabcontrol
system.windows.forms.datagridview
system.windows.forms.bindingsource
system.windows.forms.toolstripbutton
you may not able access dgv because handler public , constructor class not? i've been able access elements within handlers no issue.
Comments
Post a Comment