本文介绍了如何将焦点移动到特定字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部好,



我有一个由32个字段组成的表单,其中大部分都是强制性的。

点击保存按钮我将字段的相关名称添加到集合(字符串列表)并显示带有名称的消息框。我希望焦点移动到显示在消息框中的第一个控件。



我正在做这样的事情



按钮点击



HI All,

I have one form consisting of 32 fields in which most of them are mandatory.After
clicking on save button i am adding the field''s related name to Collections(List of string) and displaying message box with the names.I want the focus to move to the first control displaying in message box.

I am doing something like this

In button Click

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
       Try
           IsValidData()
           If m_InvalidList.Count > 0 Then
               Dim sFields As String = ""
               For iCnt As Int32 = 0 To m_InvalidList.Count - 1
                   sFields &= m_InvalidList(iCnt).ToString & vbCrLf
               Next
               XtraMessageBox.Show(" Please Fill The Following Fields : " & vbCrLf & "--------------------------------------" & vbCrLf & sFields, "Field Validator", MessageBoxButtons.OK)
           Else
               SaveGenLedgerMaster()
           End If

       Catch ex As Exception
           ErrorLog(ex)
       End Try
   End Sub













Private Sub IsValidData()
      Try
          m_InvalidList.Clear()
          If xtbGLName.Text = "" Then m_InvalidList.Add("General Ledger Name")
          If cmbGLSchedule.Text = "" Then m_InvalidList.Add("Schedule name")
          If ccbCompany.Text = "" Then m_InvalidList.Add("Company")
          If ccbSegment.Text = "" Then m_InvalidList.Add("Segment")

      Catch ex As Exception
          ErrorLog(ex)
      End Try
  End Sub







我想把控件绑定到列表中的第一个字符串。我怎么能这样做..有什么办法吗?除此之外..比如将控件添加到列表中并设置焦点...请帮帮我..




I want to focus the control binded to the first string in the List .How can i do this..is there any way other than this..like adding control to the list instead and set focus...please help me out..

推荐答案


这篇关于如何将焦点移动到特定字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 06:51