c# - How can i add to menustrip a recent files menu like in visual studio: File > Recent Files? -
and when move mouse on recent files show open list of recent opened files ?
private void recentfilestoolstripmenuitem_click(object sender, eventargs e) { toolstripmenuitem item = new toolstripmenuitem(); item.text = "your file name"; item.click += new eventhandler(youreventhandler); recentfilestoolstripmenuitem.dropdownitems.add(item); }
this recent files menu click event. i'm not sure how make remember recent opened files if close program , opend again.
and how make when move mouse on recent files menu open list.
just create simple
txt
file in root application folder namedrecentfiles.txt
.whenever open new file add list complete path.
when open application, read file , populate
dropdownlist
or wherever want show list.
you can limit recent 5 or 10 items simple logic:
- read file , populate
list
(you can use string type list) - remove last item of
list
- add current file path first item of
list
- and save item line line file(override file text, not append it)
you can refer this article practical example suggested jens horstmann
Comments
Post a Comment