如何将Hash-Map迭代到另一个方法中

时间:2016-07-27 10:18:28

标签: java android hashmap

我有这个哈希映射:

Protected Sub ServiceTypeList_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ServiceTypeList.SelectedIndexChanged
    Dim tmpservicetype As New servicetype(ServiceTypeList.SelectedItem.Value)
    Dim tmpFieldName As String

Try
    Dim cmdstr As String
    PlaceHolder1.Controls.Clear()
    lblText.Controls.Clear()

    cmdstr = "SELECT servicetype, FieldName, FieldType, FieldLength, FieldLabelEmail, ToolboxType, Height, Width, TabIndex FROM tblDynamicControl WHERE (servicetype = '" & tmpservicetype.servicetype & "') ORDER BY TabIndex"
    Dim cmd As New SqlCommand(cmdstr)

    Dim dt As DataTable = EMGEHelpdesk.SharedCode.ExecuteCMD(cmd).Tables(0)
    Dim DXTextbox As ASPxTextBox
    Dim DXLabel As ASPxLabel
    DXTextbox = New ASPxTextBox
    DXLabel = New ASPxLabel
    Dim BXRadiobutton As ASPxRadioButtonList
    Dim BXLabel As ASPxLabel
    BXRadiobutton = New ASPxRadioButtonList
    BXLabel = New ASPxLabel
    Dim MXMemobox As ASPxMemo
    Dim MXLabel As ASPxLabel
    MXMemobox = New ASPxMemo
    MXLabel = New ASPxLabel

    For i = 0 To dt.Rows.Count - 1
        Dim dr As DataRow = dt.Rows(i)
        tmpFieldName = SetDataVar(dr, "FieldName")
        Dim NewField As New DynamicControl(tmpservicetype.servicetype, tmpFieldName, "GB")

        Select Case NewField.ToolboxType
            Case "TextBox"                    
                DXTextbox.ID = NewField.FieldName & "_field"
                DXTextbox.Width = NewField.Width
                DXTextbox.Height = NewField.Height
                DXTextbox.TabIndex = NewField.TabIndex
                DXTextbox.CssClass = "Field"
                PlaceHolder1.Controls.Add(DXTextbox)
                DXLabel.ID = NewField.FieldName.ToString & "_lbl"
                DXLabel.Text = NewField.lblText
                DXLabel.CssClass = "TextBox"
                lblText.Controls.Add(DXLabel)
                DXTextbox.Controls.Add(DXLabel)

            Case "RadioButton"                    
                BXRadiobutton.DataSource = Split(NewField.FieldName)
                BXRadiobutton.DataBind()
                BXRadiobutton.RepeatDirection = RepeatDirection.Horizontal
                BXRadiobutton.ID = NewField.FieldName & "_field"
                BXRadiobutton.TabIndex = NewField.TabIndex
                BXRadiobutton.CssClass = "Button"
                PlaceHolder1.Controls.Add(BXRadiobutton)                    
                BXLabel.ID = NewField.FieldName.ToString & "_lbl"
                BXLabel.Text = NewField.lblText
                BXLabel.CssClass = "RadioButton"
                lblText.Controls.Add(BXLabel)
                BXRadiobutton.Controls.Add(BXLabel)

            Case "MemoBox"                   
                MXMemobox.ID = NewField.FieldName & "_field"
                MXMemobox.Width = NewField.Width
                MXMemobox.Height = NewField.Height
                MXMemobox.TabIndex = NewField.TabIndex
                MXMemobox.CssClass = "Field"
                PlaceHolder1.Controls.Add(MXMemobox)
                MXLabel.ID = NewField.FieldName.ToString & "_lbl"
                MXLabel.Text = NewField.lblText
                MXLabel.CssClass = "MemoBox"
                lblText.Controls.Add(MXLabel)
                MXMemobox.Controls.Add(MXLabel)
        End Select

    Next


Catch ex As Exception
    MsgBox(ex.Message)
End Try

End Sub

我如何将其迭代到另一个方法?我如何将map传递给另一个方法来迭代它?

1 个答案:

答案 0 :(得分:0)

meMap.entrySet()为您提供了这种能力

您可以像for (Entry<String, String> entry : meMap.entrySet()) {...}一样使用它或传递给其他方法