コード例 #1
0
        private void categoriesTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                bool isExist = false;
                foreach (TabPage item in blogTabControl.TabPages)
                {
                    if (item.Text == e.Node.Text)
                    {
                        isExist = true;
                        break;
                    }
                }

                if (isExist)
                {
                    blogTabControl.SelectTab(e.Node.Text);
                }
                else
                {
                    var blogs        = _blogService.GetBlogsByCategoryId(Convert.ToInt32(e.Node.Tag));
                    var dataGridView = new BlogDataGridView(blogs);

                    var tabPage = new TabPage(e.Node.Text);
                    tabPage.Name = e.Node.Text;
                    tabPage.Controls.Add(dataGridView);

                    blogTabControl.TabPages.Add(tabPage);
                    blogTabControl.SelectedTab = tabPage;
                }
            }
        }
コード例 #2
0
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (string.IsNullOrWhiteSpace(textBox1.Text))
                {
                    toolTip1.Show("搜索内容不能为空", textBox1);
                }

                var searchText   = textBox1.Text.Trim();
                var blogs        = _blogService.GetBlogsBySearchText(searchText);
                var dataGridView = new BlogDataGridView(blogs);

                var tabPage = new TabPage(searchText);
                tabPage.Name = searchText;
                tabPage.Controls.Add(dataGridView);

                blogTabControl.TabPages.Add(tabPage);
                blogTabControl.SelectedTab = tabPage;
            }
        }