Article View: alt.pl.comp.lang.csharp
Article #614Re: [Windows.Forms] tabindex + u¿ywanie entera jak klawisza tab
From: Jacek Wo³oszka
Date: Tue, 23 Mar 2004 11:17
Date: Tue, 23 Mar 2004 11:17
54 lines
2416 bytes
2416 bytes
"Tomasz Kubacki" <j23tom@[oxygene_symbol_here].pl> wrote in message
news:c3ooon$mjj$1@atlantis.news.tpi.pl...
> witam,
>
> Mam dwa textboxy:
>
> private TextBox userTextBox;
> private TextBox passTextBox;
>
> i chcia�bym przechodzi� (przerzuca� focus z jednego na drugi) u�ywaj�c
> tak�e klawisza "enter" (a nie tylko tab jak jest domy�lnie).
>
> doda�em handler:
>
> userTextBox.KeyPress += new KeyPressEventHandler(enter_pressed);
>
> z metod� obs�ugi:
>
> private void enter_pressed(object sender,KeyPressEventArgs e )
> {
> if( e.KeyChar == 0xd) //enter
> ...
> ...
>
> Tylko to rozwi�zanie wydaje mi si� brzydkie. Nie mo�na tego jako�
> �adniej ustawi� (np. w jakim� properties textboxa albo formatki)?
>
> Na pewno "jako� to si� zwyk�o robi�" - je�li kto� by�by tak mi�y i
> odpisa� by�bym wdzi�czny,
>
wyprowadz sobie klase z wlasnym textboxem i z obsluga KeyPress
np.
class TextBoxEx:..
private bool b_Enter;
public bool NextCtrl
{
get { return b_Enter; }
set { b_Enter= value;}
}
private void OnKeyPress(object sender, KeyPressEventArgs e)
{
MaskedTextBox sd = (MaskedTextBox) sender;
if (sd.b_Enter)
{
FuncjaPrzenoszacaFocus(e)
}
}
Teraz jesli utworzysz instacje tej kontrolki w klasie formualrza bedziesz
mial dodatkowa wlasnosc typu bool NextCtrl
Technical Details
Message-ID:
<c3p6e7$ru8$1@nemesis.news.tpi.pl>Path:
mbox-mo1.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!teleglobe.net!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mailReferences:
<c3ooon$mjj$1@atlantis.news.tpi.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!teleglobe.net!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail From: Jacek Wo³oszka <jacekw@grochowski.com.pl.wytnij_to> Newsgroups: alt.pl.comp.lang.csharp Subject: Re: [Windows.Forms] tabindex + u¿ywanie entera jak klawisza tab Date: Tue, 23 Mar 2004 12:17:36 +0100 Organization: tp.internet - http://www.tpi.pl/ Lines: 57 Message-ID: <c3p6e7$ru8$1@nemesis.news.tpi.pl> References: <c3ooon$mjj$1@atlantis.news.tpi.pl> NNTP-Posting-Host: qg170.internetdsl.tpnet.pl X-Trace: nemesis.news.tpi.pl 1080040712 28616 80.55.32.170 (23 Mar 2004 11:18:32 GMT) X-Complaints-To: use...@tpi.pl NNTP-Posting-Date: Tue, 23 Mar 2004 11:18:32 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit