|
分類:[.NET 全般]
はじめまして、VBのプログラムについて質問させていただきます。
VBでTree階層で表示されている名前の部分を選択し、その名前のところを削除するようなプログラムを作っています。 しかし、選択したところの名前の値が取得できない状態となっています。
そこで質問ですが、値を取得することができるようになるためには、どの部分を修正したらよいでしょうか?
#コード# Public Class MainForm
Private _SelectOrder As OrderClass Private _SelectProduct As ProductClass Private _SelectProcess As ProcessClass Private _SelectParts As PartsClass Private _LoginUser As UserClass
Public Property LoginUser() As UserClass Get Return Me._LoginUser End Get Set(ByVal value As UserClass) Me._LoginUser = value End Set End Property Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Text = " ログインユーザ " Me.TreeViewLoad()
End Sub
***********//tree階層表示//*******************************************
Private Sub TreeViewLoad()
Dim contorol As New Contoroller Dim orderlist As ArrayList = contorol.GetOrderList
Me.TreeView.Nodes.Clear()
Dim rootNode As TreeNode rootNode = New TreeNode() rootNode.Text = " 受注リスト " TreeView.Nodes.Add(rootNode)
Dim prod As ProductClass Dim proc As ProcessClass Dim parts As PartsClass Dim order As OrderClass
For Each order In orderlist
Dim myTreeNodeArray(order.ProductList.Count - 1) As TreeNode
Dim i As Integer = 0 Dim orderNode As New TreeNode("番号" + order.OrderNo + ":受注先 :" + order.OrderName) For Each prod In order.ProductList
Dim mytreeNodeArrayProcess(prod.ProcessList.Count - 1) As TreeNode Dim productNode As New TreeNode("プロダクト名 :" + prod.ProductName) productNode.ForeColor = Color.Purple myTreeNodeArray(i) = New TreeNode("プロダクト名 :" + prod.ProductName) myTreeNodeArray(i).Tag = prod i += 1
Dim j As Integer = 0 For Each proc In prod.ProcessList
Dim mytreeNodeArrayParts(proc.PartsList.Count - 1) As TreeNode Dim procNode As New TreeNode("プロセス名" + proc.ProcessName) procNode.ForeColor = Color.Green
mytreeNodeArrayProcess(j) = New TreeNode("プロセス名 :" + proc.ProcessName) mytreeNodeArrayProcess(j).Tag = proc j += 1
Dim q As Integer = 0 For Each parts In proc.PartsList Dim partsNode As New TreeNode("部品名 :" + parts.PartsName) mytreeNodeArrayParts(q) = New TreeNode("部品名 :" + parts.PartsName)
orderNode.ForeColor = Color.Red procNode.Nodes.Add(partsNode) mytreeNodeArrayParts(q).Tag = parts q += 1
Next parts productNode.Nodes.Add(procNode)
Next proc orderNode.Nodes.Add(productNode) Next prod
orderNode.Tag = order Me.TreeView.Nodes(0).Nodes.Add(orderNode) Next order With Me.TreeView .ExpandAll() .ForeColor = Color.Navy .BackColor = Color.Azure .LineColor = Color.Red .ContextMenuStrip = Me.ContextMenuStrip1 End With End Sub ********************************************************************************
***************************************************************************************: Private Sub TreeView_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView.AfterSelect Label1.Text = e.Node.Level Label2.Text = e.Node.Text
If e.Node.Level = 0 Then ToolStripMenuItem_Edit.Enabled = True ToolStripMenuItem_Add.Enabled = True ToolStripMenuItem_Delete.Enabled = True ContextMenuItem_OrderAdd.Enabled = True ContextMenuItem_OrderDelete.Enabled = True ContextMenuItem_ProcessAdd.Enabled = False ContextMenuItem_processDelete.Enabled = False ContextMenuItem_ProcessEdit.Enabled = False ContextMenuItem_ProductAdd.Enabled = False ContextMenuItem_ProductDelete.Enabled = False ElseIf e.Node.Level = 1 Then Dim order As OrderClass = TreeView.SelectedNode.Tag ToolStripMenuItem_Edit.Enabled = False ContextMenuItem_OrderAdd.Enabled = False ContextMenuItem_OrderDelete.Enabled = True ContextMenuItem_ProcessAdd.Enabled = False ContextMenuItem_processDelete.Enabled = False ContextMenuItem_ProcessEdit.Enabled = False ContextMenuItem_ProductAdd.Enabled = True ContextMenuItem_ProductDelete.Enabled = True Else ToolStripMenuItem_Edit.Enabled = False ContextMenuItem_OrderAdd.Enabled = False ContextMenuItem_OrderDelete.Enabled = False ContextMenuItem_ProcessAdd.Enabled = True ContextMenuItem_processDelete.Enabled = True ContextMenuItem_ProcessEdit.Enabled = True ContextMenuItem_ProductAdd.Enabled = False ContextMenuItem_ProductDelete.Enabled = False End If End Sub ************************************************************************
****************************削除するプログラムコード*********************************** Private Sub ContextMenuItem_OrderDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContextMenuItem_OrderDelete.Click Dim contorol As New Contoroller Dim result As Boolean
If MessageBox.Show(" 本当に削除しますか?", _ "確認", MessageBoxButtons.OKCancel, _ MessageBoxIcon.Question, _ MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.OK Then
result = contorol.DeleteOrder(Me._SelectOrder)←−−−−−−−@ここの値が取得できません@ If result = True Then MessageBox.Show("削除しました") End If End If
End Sub ****************************************************************************** End Class
#コード終わり#
です
アドバイスよろしくお願いいたします
|