The road to C# master trapemiya

C#を中心に、.NETの話題を取り上げます。

ホーム 連絡をする 同期する ( RSS 2.0 ) Login
投稿数  256  : 記事  1  : コメント  1560  : トラックバック  30

ニュース

Since 2005年10月26日

わんくま同盟

わんくま同盟

Microsoft MVP


Visual Developer - Visual C#

記事カテゴリ

書庫

日記カテゴリ

DataGridViewのセル移動方法
http://www.gdncom.jp/general/bbs/ShowPost.aspx?PostID=37120
の関係で調べていたのですが、 少しまとめてみます。

1.編集モード(セルに値を入力中)時に、KeyDownイベントでEnterキーを拾って処理しようと試したが、拾えず。orz 考えてみれば実際にはセルといってもTextBoxに対しての入力のようである。
2.そこで、EditingControlShowingイベントでEdit時に表示されるTextBoxのKeyDownイベントハンドラを登録するも、やはりEnterキーだけ拾えず。orz

結局、今のところは、DataGridViewを継承したクラスで、ProcessDialogKeyを処理することにより、逃げています。

class myDataGridView : System.Windows.Forms.DataGridView
{
    protected override bool ProcessDialogKey(Keys keyData)
    {
        if (keyData == Keys.Enter)
        {
            if (this.CurrentCell.ColumnIndex != this.ColumnCount - 1)
            {
                this.CurrentCell = this[this.CurrentCell.ColumnIndex + 1,
                                    this.CurrentCell.RowIndex];
                
                return true;
            }
            else
            {
                if (this.CurrentCell.RowIndex != this.RowCount - 1)
                    this.CurrentCell = this[0, this.CurrentCell.RowIndex];
            
                return false;
            }
        }
        return false;
    }
}
投稿日時 : 2005年10月31日 17:38

コメント

# re: [C#] DataGridViewにおいてEnterキーで右隣のセルへキャレットを飛ばす 2005/11/01 0:06 えムナウ
Enterキーを拾うには1.1のころからIsInputKeyをオーバーライドが基本ですよね。
class myDataGridView : System.Windows.Forms.DataGridView
{
protected override bool IsInputKey(System.Windows.Forms.Keys keyData)
{
if (keyData == System.Windows.Forms.Keys.Enter) return true;
return base.IsInputKey(keyData);
}
}


# re: [C#] DataGridViewにおいてEnterキーで右隣のセルへキャレットを飛ばす 2005/11/01 0:10 えムナウ
GDNJに書いておきます。


# re: [C#] DataGridViewにおいてEnterキーで右隣のセルへキャレットを飛ばす 2005/11/01 12:20 trapemiya
ありがとうございます。IsInputKeyは試していませんでした。早速試してみたのですが、やはりKeyDownのイベントを拾うことができませんでした。
私の書き方が悪かったのですが、GridViewでセルの編集モードに入った時は、実際にはTextBoxに対して値を入力しているようなのです。なので、このTextBoxのIsInputKeyをオーバーライドすればEnterキーも拾えるかもしれませんが、その方法がわかりません。(^^;

試したところ、GridViewにおいて、
1.編集モード・・・IsInputKeyは実行されない。ProcessDialogKeyは実行される。
2.編集モードじゃない・・・IsInputKeyは実行される。ProcessDialogKeyは実行されない。
3.編集モードじゃない時にセルに何か値を入力した時・・・IsInputKey、ProcessDialogKeyともに実行される。

といった、感じでした。

# re: [C#] DataGridViewにおいてEnterキーで右隣のセルへキャレットを飛ばす 2005/11/01 12:30 trapemiya
少し本文を詳しく修正しました。

# dyunzPCqogCS 2018/06/01 21:49 http://www.suba.me/
2VToOM some truly fantastic content on this internet site , thankyou for contribution.

# QYDTrSHwasH 2018/06/03 15:02 http://bit.ly/buy-edibles-online-canada
Sweet blog! I found it while browsing on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I ave been trying for a while but I never seem to get there! Appreciate it

# LiDhMXzgPj 2018/06/04 0:17 https://topbestbrand.com/คร&am
you might have a fantastic blog here! would you like to make some invite posts on my weblog?

# TUIlHaVdJf 2018/06/04 6:33 http://www.seoinvancouver.com/
Im obliged for the article.Really looking forward to read more. Great.

# wcLZJGWGbV 2018/06/04 8:26 http://www.seoinvancouver.com/
Looking forward to reading more. Great post.Much thanks again. Fantastic.

# yDpiorytrPoTylRcYh 2018/06/04 10:17 http://www.seoinvancouver.com/
I want to start a blog/online diary, but not sure where to start..

# lWjecVOzZUtlbJA 2018/06/04 12:08 http://www.seoinvancouver.com/
This is a good tip particularly to those new to the blogosphere. Short but very accurate info Many thanks for sharing this one. A must read post!

# kbTbFoBLnBXKah 2018/06/04 17:46 http://narcissenyc.com/
I will right away clutch your rss feed as I can not in finding your e-mail subscription hyperlink or newsletter service. Do you have any? Please allow me recognise so that I may subscribe. Thanks.

# ZvrlpfOvKrfRQy 2018/06/05 7:09 http://www.narcissenyc.com/
Wow, fantastic blog layout! How long have you been blogging for? you made running a blog glance easy. The total glance of your website is excellent, let alone the content material!

# OcDucOFkCwJBkCrBxTX 2018/06/05 9:03 http://seovancouver.net/
Thanks again for the blog post.Really looking forward to read more. Awesome.

# ntfXhJjFQfOnzB 2018/06/05 10:58 http://vancouverdispensary.net/
Very good publish, thanks a lot for sharing. Do you happen to have an RSS feed I can subscribe to?

# VRSZjcXJcbHlyYgGTP 2018/06/05 12:50 http://vancouverdispensary.net/
Really enjoyed this post.Really looking forward to read more. Want more.

# ULPbjGxxvEXTPS 2018/06/05 14:43 http://vancouverdispensary.net/
This web site truly has all of the info I wanted about this subject and didn at know who to ask.

# vmZjPstcTIwTKFAULGD 2018/06/05 18:29 http://vancouverdispensary.net/
There is definately a lot to learn about this issue. I really like all of the points you have made.

# FgTeTvBNeD 2018/06/05 20:25 http://vancouverdispensary.net/
Really informative article.Thanks Again. Fantastic.

# zJwWMoPgvPJNFOfZ 2018/06/06 0:31 https://www.youtube.com/watch?v=zetV8p7HXC8
readers interested about what you've got to say.

# oNfZfcJRhaoScXNQ 2018/06/08 18:57 https://topbestbrand.com/ตก&am
This is one awesome blog.Really looking forward to read more. Will read on...

I usually have a hard time grasping informational articles, but yours is clear. I appreciate how you ave given readers like me easy to read info.

# PKkwAdOeVcKIBC 2018/06/08 20:51 https://www.youtube.com/watch?v=3PoV-kSYSrs
Really excellent information can be found on web blog.

# XYgcGdjHWzYrpmkFWF 2018/06/08 21:33 http://studio-5.financialcontent.com/mi.bradenton/
LOUIS VUITTON OUTLET LOUIS VUITTON OUTLET

# eoYJrCCPanTOPwEKs 2018/06/08 22:45 https://laquitalong85.livejournal.com/
whoah this weblog is great i love reading your posts. Stay

# SCkIrhuJfrOE 2018/06/08 23:21 https://topbestbrand.com/ฉี&am
much healthier than its been in some time. Manning,

# minLtUCxCwyaJdX 2018/06/09 4:19 https://topbestbrand.com/สิ&am
Whoa! This blog looks exactly like my old one! It as on a entirely different topic but it has pretty much the same layout and design. Wonderful choice of colors!

# ZUjdgGdEmHBdlWo 2018/06/09 16:16 http://www.seoinvancouver.com/
Thanks for the article post. Really Great.

# IsdSdPIlmx 2018/06/09 18:10 http://www.seoinvancouver.com/
say it. You make it entertaining and you still care for to keep it smart.

# QebDSdKzstsVvFpCkWX 2018/06/09 22:04 http://surreyseo.net
This web site definitely has all the info I wanted about this subject and didn at know who to ask.

# WzNrJgxFOwxxzMd 2018/06/09 23:58 http://www.seoinvancouver.com/
Some truly choice posts on this website , saved to favorites.

# uTXqLoQvda 2018/06/10 7:34 http://www.seoinvancouver.com/
Some truly excellent blog posts on this internet site , thanks for contribution.

# FRxNvCihYCbgF 2018/06/10 11:22 https://topbestbrand.com/ชุ&am
Looking forward to reading more. Great blog post.Thanks Again. Want more.

# KadWOFXVme 2018/06/10 11:58 https://topbestbrand.com/เส&am
topic of unpredicted feelings. Feel free to surf to my web blog; how to Get rid Of dark Circles

# RQrlksboMMhuSGZGfFB 2018/06/11 19:30 https://tipsonblogging.com/2018/02/how-to-find-low
Very good article. I am facing a few of these issues as well..

# QqznscZqWVQ 2018/06/12 20:55 http://closestdispensaries.com/
wow, awesome blog.Thanks Again. Want more.

# IrGaHnpPOZmwIKeQUg 2018/06/12 22:54 http://naturalattractionsalon.com/
they all are tired from white teeth thats why they put gold or silver teeth!!!!

# fmmwnscEGJ 2018/06/13 2:51 http://www.seoinvancouver.com/
pretty practical stuff, overall I imagine this is really worth a bookmark, thanks

# klNkeXfsuS 2018/06/13 6:47 http://www.seoinvancouver.com/
Some genuinely prize posts on this internet site , saved to bookmarks.

# icnjWJbrEKNBTRZMFd 2018/06/13 9:31 http://www.seoinvancouver.com/
Im grateful for the post.Really looking forward to read more. Want more.

# eJbWvpMdhnlGSKlE 2018/06/13 11:26 http://www.seoinvancouver.com/
Thanks-a-mundo for the article post.Thanks Again. Want more.

# NiEBfwdLSrJStDd 2018/06/15 20:20 https://topbestbrand.com/เว&am
I truly appreciate this blog post.Much thanks again. Want more. here

# ePuDAUEYMVNkfCzpD 2018/06/16 4:59 http://signagevancouver.ca
Wow, great blog.Thanks Again. Fantastic.

# ZefQyFmDNTZVv 2018/06/16 6:55 http://claytonszdhk.suomiblog.com/an-unbiased-view
like they are left by brain dead people?

# iLqdNmdHSbyFvyBES 2018/06/18 15:34 https://www.techlovesstyle.com/single-post/2018/04
You ought to be a part of a contest for one of the highest quality blogs online. I am going to highly recommend this blog!

# BXetzUouZEdPKdqxMz 2018/06/18 21:36 https://vimeo.com/user86002144
This site was how do I say it? Relevant!! Finally I have found something which helped me. Thanks a lot!

# eBflxNVJBAWhHqXG 2018/06/18 22:57 https://www.appbrain.com/user/jihnxx001/
Look complicated to far added agreeable from you! By the way, how

# EeTTjVmZSUv 2018/06/18 23:38 https://about.me/finleypratt/
I truly appreciate this article post.Really looking forward to read more. Keep writing.

# odCZNeKbly 2018/06/19 0:19 https://fxbot.market
My brother recommended I would possibly like this blog. He was entirely right. This post actually made my

# oltGUroARIeighEm 2018/06/19 1:01 https://answers.informer.com/user/Gerald+E.+Stanle
Really appreciate you sharing this article post.

# kIofcqFIRObFJ 2018/06/19 3:47 http://iqlevel.jigsy.com/
Regards for helping out, wonderful information.

# HUIafnjSAzHHTQ 2018/06/19 5:09 https://www.whatdotheyknow.com/user/ben_morris
This is one awesome blog post.Thanks Again. Want more.

If you are going for most excellent contents like

# UWVMfHMbbLAm 2018/06/19 13:51 https://www.graphicallyspeaking.ca/
I really liked your article post.Much thanks again.

# ZoOtQBYdjj 2018/06/19 19:18 https://srpskainfo.com
You are my inhalation , I possess few web logs and very sporadically run out from to brand

Post Feedback

タイトル
名前
Url:
コメント