Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. setting focus on masked textbox control added in datagridview

setting focus on masked textbox control added in datagridview

Scheduled Pinned Locked Moved C#
helpquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nouman Bhatti
    wrote on last edited by
    #1

    Hi all, can anybody help me out here by providing me a solution. I want to set a focus to masked TextBox control displayed over a cell in CellBeginEdit event. MaskedTextbox.focus() is not working here can anybody help me out ???

    Y 1 Reply Last reply
    0
    • N Nouman Bhatti

      Hi all, can anybody help me out here by providing me a solution. I want to set a focus to masked TextBox control displayed over a cell in CellBeginEdit event. MaskedTextbox.focus() is not working here can anybody help me out ???

      Y Offline
      Y Offline
      yogesh_kumar_agarwal
      wrote on last edited by
      #2

      Do it using gridviews findcontrol method.

      N 1 Reply Last reply
      0
      • Y yogesh_kumar_agarwal

        Do it using gridviews findcontrol method.

        N Offline
        N Offline
        Nouman Bhatti
        wrote on last edited by
        #3

        I have already tried that but no success :( Control[] ctrl = datagridview.Controls.Find("name of textbox", true); ctrl[0].Focus();

        Y 1 Reply Last reply
        0
        • N Nouman Bhatti

          I have already tried that but no success :( Control[] ctrl = datagridview.Controls.Find("name of textbox", true); ctrl[0].Focus();

          Y Offline
          Y Offline
          yogesh_kumar_agarwal
          wrote on last edited by
          #4

          Try it like this.

          MaskTextBox mt=datagridview.row[0].FindControl("nameof textbox")
          mt.setFouus().

          Hope this works.

          N 1 Reply Last reply
          0
          • Y yogesh_kumar_agarwal

            Try it like this.

            MaskTextBox mt=datagridview.row[0].FindControl("nameof textbox")
            mt.setFouus().

            Hope this works.

            N Offline
            N Offline
            Nouman Bhatti
            wrote on last edited by
            #5

            there is no funciton like FindControl for datagridview and there's no function like setFocus() for maskedtextbox so r u serious in giving this solution?

            Y 1 Reply Last reply
            0
            • N Nouman Bhatti

              there is no funciton like FindControl for datagridview and there's no function like setFocus() for maskedtextbox so r u serious in giving this solution?

              Y Offline
              Y Offline
              yogesh_kumar_agarwal
              wrote on last edited by
              #6

              sorry for the late reply. But i just did the same.

                  t1 = GridView1.Rows(0).FindControl("InstallmentDec")
                  t1.Text = dt.Rows(0)(12).ToString()
              

              Its working for me. Here use Foucus function in place of setting text will work fine.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups