📄 knowledgeform.cs
字号:
//
this.label1.Location = new System.Drawing.Point(48, 16);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
this.label1.Text = "标 题";
//
// KLVPanel
//
this.KLVPanel.AutoScroll = true;
this.KLVPanel.Location = new System.Drawing.Point(24, 112);
this.KLVPanel.Name = "KLVPanel";
this.KLVPanel.Size = new System.Drawing.Size(568, 384);
this.KLVPanel.TabIndex = 1;
//
// splitter1
//
this.splitter1.Location = new System.Drawing.Point(240, 0);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(3, 504);
this.splitter1.TabIndex = 2;
this.splitter1.TabStop = false;
//
// KnowledgeForm
//
this.AutoScroll = true;
this.Controls.Add(this.splitter1);
this.Controls.Add(this.RightPanel);
this.Controls.Add(this.panel1);
this.Name = "KnowledgeForm";
this.Size = new System.Drawing.Size(856, 504);
this.Load += new System.EventHandler(this.KnowledgeForm_Load);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.treeList1)).EndInit();
this.RightPanel.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
#region 树相关的方法
private void KnowledgeForm_Load(object sender, System.EventArgs e) {
ds = bll.getKnowledgeType("KNOWLEDGETYPE");
initTreeList();
paintTreeList();
}
private void initTreeList() {
this.colTNAME = new DevExpress.XtraTreeList.Columns.TreeListColumn();
this.colOAMARK = new DevExpress.XtraTreeList.Columns.TreeListColumn();
this.colID = new DevExpress.XtraTreeList.Columns.TreeListColumn();
this.colPARENTID = new DevExpress.XtraTreeList.Columns.TreeListColumn();
//
// treeList1
//
this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] {
this.colTNAME,
this.colOAMARK,
this.colID,
this.colPARENTID});
this.treeList1.Location = new System.Drawing.Point(16, 48);
this.treeList1.Name = "treeList1";
this.treeList1.Size = new System.Drawing.Size(280, 464);
this.treeList1.TabIndex = 0;
this.treeList1.FocusedNodeChanged += new DevExpress.XtraTreeList.FocusedNodeChangedEventHandler(this.treeList1_FocusedNodeChanged);
//
// colTNAME
//
this.colTNAME.Caption = "分类名称";
this.colTNAME.FieldName = "TNAME";
this.colTNAME.Name = "colTNAME";
this.colTNAME.OptionsColumn.AllowEdit = false;
this.colTNAME.OptionsColumn.FixedWidth = true;
this.colTNAME.VisibleIndex = 0;
this.colTNAME.Width = 160;
//
// colOAMARK
//
this.colOAMARK.FieldName = "OAMARK";
this.colOAMARK.Name = "colOAMARK";
this.colOAMARK.OptionsColumn.AllowEdit = false;
this.colOAMARK.Width = 20;
//
// colID
//
this.colID.Caption = "ID";
this.colID.FieldName = "ID";
this.colID.Name = "colID";
this.colID.OptionsColumn.AllowEdit = false;
//
// colPARENTID
//
this.colPARENTID.Caption = "PARENTID";
this.colPARENTID.FieldName = "PARENTID";
this.colPARENTID.Name = "colPARENTID";
this.colPARENTID.OptionsColumn.AllowEdit = false;
}
private void treeList1_FocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e) {
// MessageBox.Show(this,e.Node.GetDisplayText(0)+" ; "+e.Node.GetDisplayText(2));
m_kType = e.Node.GetDisplayText(2);
this.tbType.Text = e.Node.GetDisplayText(0);
RetrieveLV();
}
private void paintTreeList() {
TreeListNode node;
string strexp="id="+1;
DataRow[] funrow= ds.Tables[0].Select(strexp,"");
DataRow dr = funrow[0];
node = this.treeList1.AppendNode(new Object[]{dr["TNAME"],dr["OAMARK"],dr["ID"],dr["PARENTID"]},null);
string strsel = "parentid="+dr["ID"];
DataRow[] chdr = ds.Tables[0].Select(strsel);
if(chdr.Length>0) {
digui(node,chdr);
}
this.treeList1.ExpandAll();
}
private void digui(TreeListNode pnode,DataRow[] chdr) {
TreeListNode node;
for(int i=0;i<chdr.Length;i++) {
node = this.treeList1.AppendNode(new Object[]{chdr[i]["TNAME"],chdr[i]["OAMARK"],chdr[i]["ID"],chdr[i]["PARENTID"]},pnode);
string strsel = "parentid="+chdr[i]["ID"];
DataRow[] dgdr = ds.Tables[0].Select(strsel);
if(dgdr.Length>0) {
digui(node,dgdr);
}
}
}
#endregion
#region method
private void InitKListView(){
knowledageLV.InitLV_UserDefined(m_KLVColName,DisPlayCol);
knowledageLV.Dock=DockStyle.Fill;
knowledageLV.BorderStyle = BorderStyle.Fixed3D;
knowledageLV.Columns[0].Width = 370;
knowledageLV.Columns[1].Width = 196;
knowledageLV.Columns[1].TextAlign = HorizontalAlignment.Left;
KLVPanel.Controls.Add(knowledageLV);
knowledageLV.DoubleClick+=new EventHandler(knowledageLV_DoubleClick);
this.ctMenu_Edit.MenuItems.Add("修改",new EventHandler(ctMenu_ModifyClick));
knowledageLV.ContextMenu = this.ctMenu_Edit;
}
private void RetrieveLV(){
SetKList();
if(m_KList!=null){
knowledageLV.Refresh_UserDefine(m_KList,m_KnowledgeInfo,DisPlayCol);
}
}
private void UpLoadKnowledgeInfo(){
m_KnowledgeInfo.ktitle = this.tbTitle.Text;
m_KnowledgeInfo.kkeywords = this.tbKeyWords.Text;
m_KnowledgeInfo.ktype = this.m_kType;
}
private void SetKList(){
try{
if(m_KList!=null){
m_KList.Clear();
}
UpLoadKnowledgeInfo();
m_KList =m_KnowledgeBLL.queryKnowledge(m_KnowledgeInfo);
}catch(Exception ex){
MessageBox.Show(ex.Message,"警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
private void Reset(){
this.tbTitle.Text=string.Empty;
this.tbKeyWords.Text=string.Empty;
this.tbType.Text = string.Empty;
this.m_kType = string.Empty;
}
private KnowledgeInfo GetCurrentKInfo(){
if(this.knowledageLV.SelectedIndices.Count>0 && this.m_KList.Count>0){
int index = knowledageLV.SelectedIndices[0];
KnowledgeInfo kInfo =(KnowledgeInfo)m_KList[index];
return kInfo;
}
return null;
}
#endregion
private void btnRetrieve_Click(object sender, System.EventArgs e) {
RetrieveLV();
}
private void btnReset_Click(object sender, System.EventArgs e) {
Reset();
}
private void knowledageLV_DoubleClick(object sender, EventArgs e) {
this.Cursor = Cursors.WaitCursor;
KnowledgeInfo temp_KInfo = GetCurrentKInfo();
if(temp_KInfo!=null){
KnowledgeInfo info=m_KnowledgeBLL.getKnowledgeById(temp_KInfo.id);
KnowledgeDetailForm km = new KnowledgeDetailForm(info);
km.ShowDialog();
}
this.Cursor = Cursors.Arrow;
}
private void tbTitle_TextChanged(object sender, EventArgs e) {
RetrieveLV();
}
private void tbKeyWords_TextChanged(object sender, EventArgs e) {
RetrieveLV();
}
private void ctMenu_ModifyClick(object sender, EventArgs e){
KnowledgeInfo temp_KInfo = GetCurrentKInfo();
if(temp_KInfo!=null){
KnowledgeManage_Dialog kmDlg = new KnowledgeManage_Dialog(temp_KInfo);
DialogResult dlg = kmDlg.ShowDialog();
RetrieveLV();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -