Datagrids (again)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mfleet1973@yahoo.ca

    #1

    Datagrids (again)

    Hi.

    A scenario has come up in which I'm not sure how to handle. What is
    happening is the user enters information in a cell of the grid. If the
    user then quits the application as soon as he finishes entering the
    data, the data entered in the cell is not saved. I have the following
    code in the closing event of the form:

    If DataSet.HasChan ges Then
    Try
    DataAdapter.Upd ate(DataSet.Get Changes, "Table")
    DataSet.AcceptC hanges()
    Catch e As Exception
    MsgBox(e.messag e)
    Exit Sub
    End Try
    End If

    However, if the user tabs to the next cell, the data is saved. Is
    there something that can be done to save the data without having to
    tell the users that they must tab from the cell upon entering data? I
    tried replicating a tab key press (SendKeys.Send( "{Tab}")) before
    updating but this did not fix it.

    Thanks a lot for the past and future help!

    Mike.

  • Cor Ligthert [MVP]

    #2
    Re: Datagrids (again)

    Mike,

    I have given you an aswer on this standard question some days ago in this
    newsgroup.

    Cor

    <mfleet1973@yah oo.caschreef in bericht
    news:1153328333 .053677.25740@m 73g2000cwd.goog legroups.com...
    Hi.
    >
    A scenario has come up in which I'm not sure how to handle. What is
    happening is the user enters information in a cell of the grid. If the
    user then quits the application as soon as he finishes entering the
    data, the data entered in the cell is not saved. I have the following
    code in the closing event of the form:
    >
    If DataSet.HasChan ges Then
    Try
    DataAdapter.Upd ate(DataSet.Get Changes, "Table")
    DataSet.AcceptC hanges()
    Catch e As Exception
    MsgBox(e.messag e)
    Exit Sub
    End Try
    End If
    >
    However, if the user tabs to the next cell, the data is saved. Is
    there something that can be done to save the data without having to
    tell the users that they must tab from the cell upon entering data? I
    tried replicating a tab key press (SendKeys.Send( "{Tab}")) before
    updating but this did not fix it.
    >
    Thanks a lot for the past and future help!
    >
    Mike.
    >

    Comment

    • mfleet1973@yahoo.ca

      #3
      Re: Datagrids (again)

      Hi Cor.

      Actually the last datagrid post I did was concerning visual controls
      that were not in the grid but were pointing to the same record. The
      solution was to call EndCurrentEdit of the currencymanager which fixed
      the problem.

      This issue involves changes that are done within a cell in a grid.
      User enters data in the cell, never tabbing to the next cell, and then
      quits the app which triggers saving to the db. The changes are not
      saved. I tried calling EndCurrentEdit but that did not fix the
      problem.

      Thanks!

      Cor Ligthert [MVP] wrote:
      Mike,
      >
      I have given you an aswer on this standard question some days ago in this
      newsgroup.
      >
      Cor
      >
      <mfleet1973@yah oo.caschreef in bericht
      news:1153328333 .053677.25740@m 73g2000cwd.goog legroups.com...
      Hi.

      A scenario has come up in which I'm not sure how to handle. What is
      happening is the user enters information in a cell of the grid. If the
      user then quits the application as soon as he finishes entering the
      data, the data entered in the cell is not saved. I have the following
      code in the closing event of the form:

      If DataSet.HasChan ges Then
      Try
      DataAdapter.Upd ate(DataSet.Get Changes, "Table")
      DataSet.AcceptC hanges()
      Catch e As Exception
      MsgBox(e.messag e)
      Exit Sub
      End Try
      End If

      However, if the user tabs to the next cell, the data is saved. Is
      there something that can be done to save the data without having to
      tell the users that they must tab from the cell upon entering data? I
      tried replicating a tab key press (SendKeys.Send( "{Tab}")) before
      updating but this did not fix it.

      Thanks a lot for the past and future help!

      Mike.

      Comment

      • jeff

        #4
        Re: Datagrids (again)

        so,

        if i understand correctly, the user makes changes in a cell ... than exits
        the application - presses the close button on the window control bar ... the
        data is not changed in the dataadapter because the cell did not lose focus
        and the change is not ackonwledged ...

        in the closing event, get the current cell with focus and set the focus to
        the next cell ... force a tab or something ... or set focus to another
        control on the window ... anything to move the cursor / focus out of the
        curent cell ... this should force the data change to be acknowledge and the
        EndCurrentEdit should work...and thus the update to save the data ...



        <mfleet1973@yah oo.cawrote in message
        news:1153330154 .842194.171560@ i42g2000cwa.goo glegroups.com.. .
        Hi Cor.
        >
        Actually the last datagrid post I did was concerning visual controls
        that were not in the grid but were pointing to the same record. The
        solution was to call EndCurrentEdit of the currencymanager which fixed
        the problem.
        >
        This issue involves changes that are done within a cell in a grid.
        User enters data in the cell, never tabbing to the next cell, and then
        quits the app which triggers saving to the db. The changes are not
        saved. I tried calling EndCurrentEdit but that did not fix the
        problem.
        >
        Thanks!
        >
        Cor Ligthert [MVP] wrote:
        >Mike,
        >>
        >I have given you an aswer on this standard question some days ago in this
        >newsgroup.
        >>
        >Cor
        >>
        ><mfleet1973@ya hoo.caschreef in bericht
        >news:115332833 3.053677.25740@ m73g2000cwd.goo glegroups.com.. .
        Hi.
        >
        A scenario has come up in which I'm not sure how to handle. What is
        happening is the user enters information in a cell of the grid. If the
        user then quits the application as soon as he finishes entering the
        data, the data entered in the cell is not saved. I have the following
        code in the closing event of the form:
        >
        If DataSet.HasChan ges Then
        Try
        DataAdapter.Upd ate(DataSet.Get Changes, "Table")
        DataSet.AcceptC hanges()
        Catch e As Exception
        MsgBox(e.messag e)
        Exit Sub
        End Try
        End If
        >
        However, if the user tabs to the next cell, the data is saved. Is
        there something that can be done to save the data without having to
        tell the users that they must tab from the cell upon entering data? I
        tried replicating a tab key press (SendKeys.Send( "{Tab}")) before
        updating but this did not fix it.
        >
        Thanks a lot for the past and future help!
        >
        Mike.
        >
        >

        Comment

        • Izzy

          #5
          Re: Datagrids (again)

          On validating of the grid control throw a boolean variable "IsDirty"
          and on closing of the form:

          If IsDirty then
          If MsgBox("You have unsaved changes. Would you like to save your
          changes now?", MsgBoxStyle.Yes No) = MsgBoxResult.Ye s Then e.Cancel =
          True
          End If

          jeff wrote:
          so,
          >
          if i understand correctly, the user makes changes in a cell ... than exits
          the application - presses the close button on the window control bar ... the
          data is not changed in the dataadapter because the cell did not lose focus
          and the change is not ackonwledged ...
          >
          in the closing event, get the current cell with focus and set the focus to
          the next cell ... force a tab or something ... or set focus to another
          control on the window ... anything to move the cursor / focus out of the
          curent cell ... this should force the data change to be acknowledge and the
          EndCurrentEdit should work...and thus the update to save the data ...
          >
          >
          >
          <mfleet1973@yah oo.cawrote in message
          news:1153330154 .842194.171560@ i42g2000cwa.goo glegroups.com.. .
          Hi Cor.

          Actually the last datagrid post I did was concerning visual controls
          that were not in the grid but were pointing to the same record. The
          solution was to call EndCurrentEdit of the currencymanager which fixed
          the problem.

          This issue involves changes that are done within a cell in a grid.
          User enters data in the cell, never tabbing to the next cell, and then
          quits the app which triggers saving to the db. The changes are not
          saved. I tried calling EndCurrentEdit but that did not fix the
          problem.

          Thanks!

          Cor Ligthert [MVP] wrote:
          Mike,
          >
          I have given you an aswer on this standard question some days ago in this
          newsgroup.
          >
          Cor
          >
          <mfleet1973@yah oo.caschreef in bericht
          news:1153328333 .053677.25740@m 73g2000cwd.goog legroups.com...
          Hi.

          A scenario has come up in which I'm not sure how to handle. What is
          happening is the user enters information in a cell of the grid. If the
          user then quits the application as soon as he finishes entering the
          data, the data entered in the cell is not saved. I have the following
          code in the closing event of the form:

          If DataSet.HasChan ges Then
          Try
          DataAdapter.Upd ate(DataSet.Get Changes, "Table")
          DataSet.AcceptC hanges()
          Catch e As Exception
          MsgBox(e.messag e)
          Exit Sub
          End Try
          End If

          However, if the user tabs to the next cell, the data is saved. Is
          there something that can be done to save the data without having to
          tell the users that they must tab from the cell upon entering data? I
          tried replicating a tab key press (SendKeys.Send( "{Tab}")) before
          updating but this did not fix it.

          Thanks a lot for the past and future help!

          Mike.

          Comment

          • Cor Ligthert [MVP]

            #6
            Re: Datagrids (again)

            Mike,

            Simple,

            Don't start with this, a datagrid has in front a little pencil to
            acknowledge the editing, so let the user do that. You are now building an
            application that is not working confirm the standards of that control.

            Just my thought,

            Cor

            <mfleet1973@yah oo.caschreef in bericht
            news:1153328333 .053677.25740@m 73g2000cwd.goog legroups.com...
            Hi.
            >
            A scenario has come up in which I'm not sure how to handle. What is
            happening is the user enters information in a cell of the grid. If the
            user then quits the application as soon as he finishes entering the
            data, the data entered in the cell is not saved. I have the following
            code in the closing event of the form:
            >
            If DataSet.HasChan ges Then
            Try
            DataAdapter.Upd ate(DataSet.Get Changes, "Table")
            DataSet.AcceptC hanges()
            Catch e As Exception
            MsgBox(e.messag e)
            Exit Sub
            End Try
            End If
            >
            However, if the user tabs to the next cell, the data is saved. Is
            there something that can be done to save the data without having to
            tell the users that they must tab from the cell upon entering data? I
            tried replicating a tab key press (SendKeys.Send( "{Tab}")) before
            updating but this did not fix it.
            >
            Thanks a lot for the past and future help!
            >
            Mike.
            >

            Comment

            • Matt

              #7
              Re: Datagrids (again)

              Have you stepped through to see if the .HasChanges is returning as true?
              I'm guessing here, but maybe the change to the cell in the datagrid isn't
              making the change to the DataSet until after the cell loses focus.

              Also I don't think the .AcceptChanges is necessary as calling the
              DataAdapter.Upd ate should set all rowstates to unchanged.

              <mfleet1973@yah oo.cawrote in message
              news:1153328333 .053677.25740@m 73g2000cwd.goog legroups.com...
              Hi.
              >
              A scenario has come up in which I'm not sure how to handle. What is
              happening is the user enters information in a cell of the grid. If the
              user then quits the application as soon as he finishes entering the
              data, the data entered in the cell is not saved. I have the following
              code in the closing event of the form:
              >
              If DataSet.HasChan ges Then
              Try
              DataAdapter.Upd ate(DataSet.Get Changes, "Table")
              DataSet.AcceptC hanges()
              Catch e As Exception
              MsgBox(e.messag e)
              Exit Sub
              End Try
              End If
              >
              However, if the user tabs to the next cell, the data is saved. Is
              there something that can be done to save the data without having to
              tell the users that they must tab from the cell upon entering data? I
              tried replicating a tab key press (SendKeys.Send( "{Tab}")) before
              updating but this did not fix it.
              >
              Thanks a lot for the past and future help!
              >
              Mike.
              >

              Comment

              Working...