主婦と.NETと犬のぶろぐ

奥様 と プログラム と お犬様 の 楽しい日常

目次

Blog 利用状況

ニュース

書庫

日記カテゴリ

MenuStrip(System.Windows.Forms.MenuStrip)

ちょっと間があいてしまいましたが...
MenuStrip って ContextMenuStrip と似てるというか、ほとんど同じ。
おもしろいのが MdiWindowListItem プロパティですかね。
自分で何も実装しなくても、開いている子画面のメニューが勝手にぽこぽこできる。

あと、全然用途がなさそうですが NumericUpDown メニューを作ってみました。
ToolStripControlHost を継承すればサルでも出来てしまうじゃないかと思うくらい簡単。

■参考文献
MenuStrip コントロール (Windows フォーム)
MenuStrip クラス
ToolStripControlHost クラス

■実行画像
MdiWindowListItem に設定したメニュー
MenuStrip MdiWindowListItem

Public Class MenuStripTest

Private Sub MenuStripTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' 自身を MDI の親に設定 Me.IsMdiContainer = True ' MenuStrip を追加 Dim mm As MenuStrip = New MenuStrip() Me.Controls.Add(mm) Me.MainMenuStrip = mm
Dim mdiWindowListItem As ToolStripMenuItem = New ToolStripMenuItem("MdiWindow") Dim childShowItem As ToolStripMenuItem = New ToolStripMenuItem("&Open") mdiWindowListItem.DropDownItems.Add(childShowItem) AddHandler childShowItem.Click, AddressOf ShowChildForm
Dim testItem As ToolStripMenuItem = New ToolStripMenuItem("test") ' ショートカットキーを使う testItem.Text = "Test Ctrl+T" testItem.ShortcutKeys = System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.T 'CType(, System.Windows.Forms.Keys) ' ToolTipText を設定する testItem.ToolTipText = "Open と同じです" AddHandler testItem.Click, AddressOf ShowChildForm
With mm .Dock = DockStyle.Top ' Grip を可視にする .GripStyle = ToolStripGripStyle.Visible ' MDI の子フォームのリストを表示するために使用される ToolStripMenuItem .MdiWindowListItem = mdiWindowListItem .Items.Add(mdiWindowListItem) ' 別に MdiWindowListItem にセットしなくとも普通に子画面は開ける ' 開いている Form の一覧が MdiWindowListItem に表示される .Items.Add(testItem) ' Item に ToolTipText を設定しても、ShowItemToolTips = True じゃないと表示されない .ShowItemToolTips = True
' プログレスバーを表示してみる Dim progressBar As ToolStripProgressBar = New ToolStripProgressBar() progressBar.Minimum = 0 progressBar.Maximum = 100 progressBar.Value = 50 .MdiWindowListItem.DropDownItems.Add(progressBar) DirectCast(.MdiWindowListItem.DropDown, ToolStripDropDownMenu).ShowCheckMargin = False End With
'' 独自のアイテムを追加する Dim originMenu As ToolStripMenuItem = New ToolStripMenuItem() originMenu.Text = "Original" mm.Items.Add(originMenu) Dim numericItem As NumericUpDownItem = New NumericUpDownItem() originMenu.DropDownItems.Add(numericItem) End Sub
Private Sub ShowChildForm(ByVal sender As Object, ByVal e As EventArgs) Dim children As Form = New Form() children.Text = DateTime.Now.ToString("yyyyMMddHHmmss") children.MdiParent = Me children.Size = New Size(100, 100) children.Show() End Sub End Class
' 独自のメニュー項目を作成する ' http://msdn2.microsoft.com/ja-jp/library/system.windows.forms.toolstripcontrolhost(VS.80).aspx Public Class NumericUpDownItem Inherits ToolStripControlHost
Public Sub New() MyBase.New(New NumericUpDown()) End Sub
Public ReadOnly Property NumericUpDown() As NumericUpDown Get Return DirectCast(MyBase.Control, NumericUpDown) End Get End Property
Public Event ValueChanged As EventHandler
Protected Overrides Sub OnSubscribeControlEvents(ByVal c As Control) MyBase.OnSubscribeControlEvents(c) Dim numericUpDownctrl As NumericUpDown = DirectCast(c, NumericUpDown)
' NumericUpDown を生で公開してるから別にやらんでもいいようなきもしますが... AddHandler numericUpDownctrl.ValueChanged, _ AddressOf OnValueChanged End Sub
Protected Overrides Sub OnUnsubscribeControlEvents(ByVal c As Control) MyBase.OnUnsubscribeControlEvents(c) Dim numericUpDownctrl As NumericUpDown = DirectCast(c, NumericUpDown)
RemoveHandler numericUpDownctrl.ValueChanged, _ AddressOf OnValueChanged End Sub
Private Sub OnValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) RaiseEvent ValueChanged(Me, e) End Sub End Class

投稿日時 : 2007年2月22日 10:09

Feedback

# lypPYfowQrBllSJOlb 2012/01/07 12:57 http://www.luckyvitamin.com/m-599-solaray

Yeah, it is clear now !... From the very beginning I did not understand where was the connection with the title !!...

# re: Internet Explorer 11 で、右クリックしたときに表示されるメニューで、Bingではなく、Google をデフォルトの検索エンジンとして設定するには? 2017/12/08 18:12 meadc

http://www.nfl-shop.co nfl store
http://www.nike-chaussures.fr/ Air Max TN Homme
http://www.culinar-hannover.de/ Nike Air Force
http://www.pradahandbags.co prada handbags
http://www.burberry-outletsale.us/ burberry outlet sale store
me adc12.8

# VuwEagrHTMqPTW 2019/04/22 19:48 https://www.suba.me/

d6q274 you made blogging look easy. The overall look of your website is

# WgwYUQPauNJnewky 2019/04/28 2:11 https://is.gd/vJucoo

wonderful. ? actually like whаА а?а?t you hаА а?а?ve acquired here, certainly like what you arаА а?а? stating and

# CIbvPIaaQDy 2019/04/28 3:38 http://bit.do/ePqUC

Utterly pent content, appreciate it for information. No human thing is of serious importance. by Plato.

# nwPewGitZrb 2019/04/28 5:43 https://is.gd/SbKOPo

Really appreciate you sharing this article post.

# rxInGcOzwecF 2019/04/29 19:19 http://www.dumpstermarket.com

Well I really enjoyed studying it. This article offered by you is very practical for proper planning.

# lqHKxvOujLnqo 2019/05/01 0:38 http://guidemom.com/index.php?qa=user&qa_1=cra

You should take part in a contest for one of the best blogs on the web. I will recommend this web site!

# QeGfZylpzYHS 2019/05/01 20:08 http://katava.info/__media__/js/netsoltrademark.ph

You have brought up a very wonderful details , thanks for the post.

# beNhdovBHDxP 2019/05/02 23:39 https://www.ljwelding.com/hubfs/tank-growing-line-

That is a great tip especially to those fresh to the blogosphere. Short but very precise info Thanks for sharing this one. A must read post!

# FZmNQNMHVlMVfrD 2019/05/03 4:12 http://ijepafubange.mihanblog.com/post/comment/new

Your method of telling the whole thing in this article is actually pleasant, all be able to effortlessly understand it, Thanks a lot.

# rcPGxeHzvQ 2019/05/03 8:46 http://gurdk.ru/go.php?to=http%3A%2F%2Flgdc.maho.o

You must participate in a contest for top-of-the-line blogs on the web. I will advocate this website!

# WSqmMcwWMlMrdOe 2019/05/03 12:38 https://mveit.com/escorts/united-states/san-diego-

some fastidious points here. Any way keep up wrinting.

# WjxAEfwohKJ 2019/05/03 16:57 https://www.youtube.com/watch?v=xX4yuCZ0gg4

too substantially vitamin-a may also lead to osteoporosis but aging could be the quantity cause of it`

# cRYPurjWpkDvmW 2019/05/03 20:34 https://mveit.com/escorts/united-states/houston-tx

Thanks for sharing, this is a fantastic post.Much thanks again. Fantastic.

# plCLrBjPbXLHdEHoPA 2019/05/03 21:44 https://talktopaul.com/pasadena-real-estate

ohenkt foo theoing, ohit it e fenoetoic bkog poto.owekky ohenk you! ewwtomw.

# fwJzznAIZx 2019/05/03 23:39 https://mveit.com/escorts/united-states/los-angele

I was recommended this website by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my trouble. You are incredible! Thanks!

# glNodrqMBCz 2019/05/04 2:51 http://all4webs.com/offerhawk82/qbnrbykvvv540.htm

Very good information. Lucky me I came across your website by chance (stumbleupon). I ave saved as a favorite for later!

# vOjgiktvxKHOUp 2019/05/04 4:46 https://timesofindia.indiatimes.com/city/gurgaon/f

Very good day i am undertaking research at this time and your website actually aided me

# JQTxSELbYAtEUYQuUq 2019/05/05 18:50 https://docs.google.com/spreadsheets/d/1CG9mAylu6s

I will not talk about your competence, the article simply disgusting

# trvazFwOZYOihsv 2019/05/07 17:55 https://www.mtcheat.com/

you heard about this new site ? Dallas SEO

# mgFyOhwPXCTavDe 2019/05/08 21:22 https://ysmarketing.co.uk/

It as hard to come by well-informed people about this topic, but you seem like you know what you are talking about! Thanks

# JnQbkHwdnKO 2019/05/09 1:39 http://www.skyads.aero/author/aspenpark/

I really liked your article.Thanks Again. Awesome.

# MwTEtnZlYuNsEdPMTSg 2019/05/09 1:43 https://www.youtube.com/watch?v=Q5PZWHf-Uh0

You have a number of truly of the essence in a row printed at this point. Excellent job and keep reorganization superb stuff.

# tEcQWtJDlIwBXRjNrnq 2019/05/09 10:14 https://photoshopcreative.co.uk/user/BrianaLopez

Wow! This can be one particular of the most useful blogs We have ever arrive across on this subject. Actually Magnificent. I am also an expert in this topic therefore I can understand your hard work.

# VWMZIUcmjntAGW 2019/05/09 16:40 https://reelgame.net/

Your style is so unique in comparison to other people I ave read stuff from.

# quJPOOJzABlhOcHGIW 2019/05/10 1:05 https://www.ttosite.com/

Im obliged for the blog post.Thanks Again. Really Great.

# gLLHEcrtQtgpTGezEE 2019/05/10 13:50 https://ruben-rojkes.weeblysite.com/

I truly appreciate this post. I ave been looking everywhere for this! Thank goodness I found it on Bing. You ave made my day! Thx again.

# eLBhXcOEQveOCRoz 2019/05/10 20:16 https://cansoft.com

I simply could not leave your website before suggesting that I extremely enjoyed the standard info an individual supply to your guests? Is going to be again ceaselessly in order to inspect new posts.

# ESDdNBURUbtzt 2019/05/11 0:54 https://www.youtube.com/watch?v=Fz3E5xkUlW8

There is visibly a bunch to realize about this. I believe you made certain good points in features also.

# WBydJYBPaFjtufHO 2019/05/11 6:28 http://hannahfoundation.com/__media__/js/netsoltra

Really enjoyed this post.Much thanks again. Want more.

# OlMTueoLmcmRMQMNO 2019/05/12 23:00 https://www.sftoto.com/

Right away I am going to do my breakfast, after having my breakfast coming yet again to read more news.

# WiVKZZIOtaRyBwFdHiG 2019/05/13 2:47 https://reelgame.net/

You, my pal, ROCK! I found just the information I already searched all over the place and simply could not find it. What a great web site.

# iKZReToDTmblV 2019/05/14 21:49 https://bgx77.com/

This is a really good tip particularly to those fresh to the blogosphere. Simple but very accurate info Appreciate your sharing this one. A must read article!

# jlCPpmhMzdxGD 2019/05/15 9:46 http://yw.xlbbusa.com/home.php?mod=space&uid=3

Would love to incessantly get updated great web site!.

# GjaKqwhJtHriaFdPyb 2019/05/15 11:54 https://www.navy-net.co.uk/rrpedia/Automotive_auto

Very good article! We are linking to this particularly great post on our site. Keep up the great writing.

# zMUOHeNdQQihescezf 2019/05/15 14:25 https://www.talktopaul.com/west-hollywood-real-est

much healthier than its been in some time. Manning,

# YhbWUgmcjoQhAWNqhdf 2019/05/15 21:53 http://biznes-kniga.com/poleznoe/ritualnye_uslugi.

If you want to grow your familiarity just keep visiting this web

# ebPCQGSvHJcgTBnPMiS 2019/05/16 21:02 https://www.lush-fab-glam.com/2014/11/holiday-shop

Wow that was odd. I just wrote an extremely long comment but after I clicked submit my comment didn at appear. Grrrr well I am not writing all that over again. Anyway, just wanted to say great blog!

# jgmXoaxpdCUja 2019/05/16 21:24 https://reelgame.net/

Its hard to find good help I am constantnly saying that its difficult to get good help, but here is

# efkflZatqwpSW 2019/05/16 23:39 http://images.google.com.np/url?q=http://getcosmet

Really appreciate you sharing this post.Thanks Again. Really Great.

# ZssXnnHjnQYehZf 2019/05/17 5:38 https://www.ttosite.com/

Then you all know which is right for you.

# OUeScMqGktZkWz 2019/05/17 6:05 https://www.youtube.com/watch?v=Q5PZWHf-Uh0

Very good article. I will be facing some of these issues as well..

# tOTlbafdptA 2019/05/18 4:34 http://miracletour.com/bitrix/rk.php?goto=http://w

This is a great tip particularly to those new to the blogosphere. Simple but very accurate information Appreciate your sharing this one. A must read post!

# RrrEsopuuIGLZwsNd 2019/05/18 12:19 https://www.dajaba88.com/

pretty useful material, overall I imagine this is really worth a bookmark, thanks

# JCqGFfaGPqevANawx 2019/05/20 17:04 https://nameaire.com

WONDERFUL Post. thanks pertaining to share.. more wait around..

# NaEEgvPSiS 2019/05/20 21:19 https://www.navy-net.co.uk/rrpedia/How_To_Use_E-ma

You are my function models. Thanks for the write-up

# nlCJtjfDcujHwhrXey 2019/05/21 19:20 http://europeanaquaponicsassociation.org/members/a

Really good info! Also visit my web-site about Clomid challenge test

# bLENhjqleXNMymmacm 2019/05/21 21:46 https://nameaire.com

Very good blog! Do you have any tips and hints for aspiring writers?

タイトル  
名前  
Url
コメント