블로그 이미지
Sunny's

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Notice

'델리게이트'에 해당되는 글 1

  1. 2009.08.14 컨트롤 델리게이트 이용 실행
2009. 8. 14. 20:56 .NET Framework


  
        public enum RichTextBoxCommand
        {
            AppendText,
            ScrollToCaret
        }

        public delegate void DelegateRichTextBox(RichTextBox rebTextBox, RichTextBoxCommand command, String sAppendText);
        public DelegateRichTextBox dgRichText;

        public void SetRichTextBox(RichTextBox rebTextBox, RichTextBoxCommand command, String sAppendText)
        {
            switch (command)
            {
                case RichTextBoxCommand.AppendText:
                    rebTextBox.AppendText(sAppendText);
                    break;
                case RichTextBoxCommand.ScrollToCaret:
                    rebTextBox.ScrollToCaret();
                    break;
                default:
                    break;
            }

            rebTextBox.ScrollToCaret();
        }


        public void MoveTextBoxScroll()
        {

            txtChatBox.ScrollToCaret();
        }

        public enum ListBoxCommand
        {
            Add,
            AddRange,
            Remove,
            Clear
        }

        public delegate void DelegateListItem(ListBox lstListBox, ListBoxCommand command, String sItem, String[] arrItems);
        public DelegateListItem ListItemDelegate;

        public void SetListBox(ListBox lstListBox, ListBoxCommand command, String sItem, String[] arrItems)
        {
            switch (command)
            {
                case ListBoxCommand.Add:
                    lstListBox.Items.Add(sItem);
                    break;
                case ListBoxCommand.AddRange:
                    lstListBox.Items.Clear();
                    lstListBox.Items.AddRange(arrItems);
                    lstListBox.Items.RemoveAt(lstListBox.Items.Count - 1);
                    break;
                case ListBoxCommand.Remove:
                    lstListBox.Items.Remove(sItem);
                    break;
                case ListBoxCommand.Clear:
                    lstListBox.Items.Clear();
                    break;
                default:
                    break;
            }
           
        }

posted by Sunny's
prev 1 next