문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
jcontrols_cf35:jmessagebox [2016/03/18 22:59] Comfile Technology [Open 메소드 함수] |
jcontrols_cf35:jmessagebox [2016/04/14 09:46] (현재) |
||
---|---|---|---|
줄 1: | 줄 1: | ||
+ | ====== jMessageBox ====== | ||
+ | ''jMessageBox'' 는 메세지를 표시하거나, 질문에 대한 응답을 받기위한 콘트롤입니다. 닷넷 프레임웍에도 멧세지 박스 기능이 기본적으로 있습니다만, jMessageBox로 하면 보다 근사한 화면을 만드실 수 있습니다. | ||
+ | Visual Studio에서는 jMessageBox는 무조건 보이도록 되어 있지만, ''Visible'' 속성이 디폴트로 ''false''로 되어 있어서, Windows CE 디바이스에서는 보이지 않습니다. 이것을 보이도록 하려면 ''Visible'' 속성을 ''true''로 변경하면 됩니다. 또는 [[.:jMessageBox#open_메소드_함수|Open 메소드 함수]] 이용해서 불러낼 수 있습니다. | ||
+ | |||
+ | 평소에는 jMessageBox를 감추고 있다가, 필요할 때 표시하는 식으로 사용합니다. | ||
+ | |||
+ | ===== Properties ===== | ||
+ | |||
+ | ==== Button Properties ==== | ||
+ | jMessageBox에는 3개의 버튼이 있고 각각의 버튼에 대한 속성을 조정할 수 있습니다. | ||
+ | |||
+ | {{ .:messageboxchildcontrols.png?nolink |}} | ||
+ | |||
+ | 버튼을 여러분이 원하는 형태로 바꾸어서 커스터마이징하실 수 있습니다. | ||
+ | |||
+ | {{ .:messageboxcustombutton.png?nolink |}} | ||
+ | |||
+ | ==== Button Text 속성 ==== | ||
+ | 또한 jMessageBox은 4개의 text속성을 조정할 수 있도록 되어 있습니다. ''CancelText'', ''NoText'', ''OKText'', ''YesText''. 이 속성에 들어있는 Text를 한글로 변경하면 한글이 표시됩니다. [[.:jmessagebox#open_메소드_함수|Open 메소드 함수]] 의 ''jMessageBox.Buttons'' 인자를 조정하여 어떤 보턴을 표시할 것인지 결정할 수 있습니다. | ||
+ | |||
+ | |{{ .:messageboxbuttontext.png?nolink |}}|{{ .:messageboxbuttontextproperties.png?nolink |}}| | ||
+ | ==== MessageLabel 속성 ==== | ||
+ | ''MessageLabel'' 속성에 표시할 멧세지를 입력하시면 됩니다. | ||
+ | |||
+ | {{ .:messageboxcustomlabel.png?nolink |}} | ||
+ | |||
+ | ===== Methods ===== | ||
+ | |||
+ | ==== Open 메소드 함수 ==== | ||
+ | |||
+ | <code csharp> | ||
+ | public void Open(Action<DialogResult> handleResult, string message); | ||
+ | public void Open(Action<DialogResult> handleResult, string message, string caption); | ||
+ | public void Open(Action<DialogResult> handleResult, string message, string caption, jMessageBox.Buttons buttons); | ||
+ | </code> | ||
+ | |||
+ | ''handleResult'' - 3 버튼중 하나가 눌려졌을 때 실행할 콜백 함수\\ | ||
+ | ''message'' - [[.:jmessagebox#messagelabel_속성|MessageLabel]]에 표시할 멧세지\\ | ||
+ | ''caption'' - message box의 타이틀에 표시할 Text.\\ | ||
+ | ''buttons'' - 다음 4개중 하나를 사용할 수 있습니다; ''OK'', ''OKCancel'', ''YesNo'', ''YesNoCancel''\\ | ||
+ | |||
+ | ''Open'' 메소드 함수를 호출하면 멧세지박스를 표시합니다. 버튼중 하나를 누르면, 멧세지 박스는 사라집니다. 그리고 ''handleResult'' 콜백 함수를 콜합니다. 누른 버튼에 해당하는 [[https://msdn.microsoft.com/en-us/library/system.windows.forms.dialogresult%28v=vs.90%29.aspx|DialogResult]] 가 반환됩니다. | ||
+ | |||
+ | === 사용예제 === | ||
+ | 4개의 버튼 옵션이 각각 어떻게 동작하는지 알 수 있는 예제입니다. (''_okButton'', ''_okCancelButton'', ''_yesNoButton'', ''_yesNoCancelButton''). 아래에는 ''_resultLabel'' 라벨이 하나 있습니다. 여기에 멧세지박스가 클로즈되었을때의 결과를 표시하도록 하였습니다. | ||
+ | |||
+ | <code csharp> | ||
+ | void DisplayResult(DialogResult result) | ||
+ | { | ||
+ | _resultLabel.Text = result.ToString(); | ||
+ | } | ||
+ | |||
+ | private void _okButton_Click(object sender, EventArgs e) | ||
+ | { | ||
+ | _messageBox.Open(DisplayResult, "Press OK Button", ((Control)sender).Text, jMessageBox.Buttons.OK); | ||
+ | } | ||
+ | |||
+ | private void _okCancelButton_Click(object sender, EventArgs e) | ||
+ | { | ||
+ | _messageBox.Open(DisplayResult, "Press OK or Cancel Button", ((Control)sender).Text, jMessageBox.Buttons.OKCancel); | ||
+ | } | ||
+ | |||
+ | private void _yesNoButton_Click(object sender, EventArgs e) | ||
+ | { | ||
+ | _messageBox.Open(DisplayResult, "Press Yes or No Button", ((Control)sender).Text, jMessageBox.Buttons.YesNo); | ||
+ | } | ||
+ | |||
+ | private void _yesNoCancelButton_Click(object sender, EventArgs e) | ||
+ | { | ||
+ | _messageBox.Open(DisplayResult, "Press, Yes, No, or Cancel Button", ((Control)sender).Text, jMessageBox.Buttons.YesNoCancel); | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | {{ .:messagebox.mp4?854x480 }} |