c# - Copy button label to clipboard -
i'm using
private void form1_load(object sender, eventargs e) { int = 1; var alllines = file.readalllines(@"c:\text.txt"); foreach (var line in alllines) { var b = new button(); b.text = line; b.autosize = true; b.location = new point(22, b.size.height * i); this.controls.add(b); i++; } }
to create bunch of buttons text file
how can control behaviour of buttons - want them copy label clipboard
add before this.controls.add(b)
line:
b.click += eventhandler((s, e) => clipboard.settext(line));
this creates handler click event copies line clipboard.
for more information windows forms programming starting point microsoft's own windowsclient.net website. lot of information skewed towards wpf these days there should still plenty of forms stuff around.
Comments
Post a Comment