Data Grid problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shailja
    New Member
    • Feb 2007
    • 123

    Data Grid problem

    Hi,

    I am using vb. I have data grid on my form. At runtime i am not able to enter data into data grid. I think grid is locked. Do i need to set any property or need to write code to enter as many records as i want at runtime?

    I am using DataGrid. Is it ok or i should use DBGrid. My back end is access.
    Please help me soon. It is quite urgent.
  • vijaydiwakar
    Contributor
    • Feb 2007
    • 579

    #2
    Originally posted by Shailja
    Hi,

    I am using vb. I have data grid on my form. At runtime i am not able to enter data into data grid. I think grid is locked. Do i need to set any property or need to write code to enter as many records as i want at runtime?

    I am using DataGrid. Is it ok or i should use DBGrid. My back end is access.
    Please help me soon. It is quite urgent.
    y dont' u go for Componants VsFlexGrid

    Comment

    • ansumansahu
      New Member
      • Mar 2007
      • 149

      #3
      Originally posted by Shailja
      Hi,

      I am using vb. I have data grid on my form. At runtime i am not able to enter data into data grid. I think grid is locked. Do i need to set any property or need to write code to enter as many records as i want at runtime?

      I am using DataGrid. Is it ok or i should use DBGrid. My back end is access.
      Please help me soon. It is quite urgent.
      Hi ,

      Refer to this link

      http://msdn2.microsoft .com/en-us/library/y4ddh1ac(vs.80) .aspx

      it might help you solve your problem.

      thanks
      ansuman sahu

      Comment

      • cmrhema
        Contributor
        • Jan 2007
        • 375

        #4
        The link by ansuman will help you if you are using visual studio 2005
        The below is the exact link for it (i presume)
        Please do read the tutorial carefully


        First check out the allowaddnew property set it to true
        Thereafter if you are using a adodc control then set the relevant properties.
        After setting the properties of adodc control right click on the datagrid and choose retrieve fields.

        In case you are going to code then set the recordset to the datagrid
        here's an example
        Here Myrs2 is the record set
        'Set on the cursor location
        MyRs2.CursorLoc ation = adUseClient
        MyRs2.Open "select * from investmentdetai ls ", MyCon, adOpenDynamic, adLockOptimisti c
        'Set the datasource to the record set
        Set DataGrid1.DataS ource = MyRs2

        NEXT TIME ONWARDS PLEASE PUT ON YOUR CODE

        Good luck

        Comment

        • Shailja
          New Member
          • Feb 2007
          • 123

          #5
          Originally posted by cmrhema
          The link by ansuman will help you if you are using visual studio 2005
          The below is the exact link for it (i presume)
          Please do read the tutorial carefully


          First check out the allowaddnew property set it to true
          Thereafter if you are using a adodc control then set the relevant properties.
          After setting the properties of adodc control right click on the datagrid and choose retrieve fields.

          In case you are going to code then set the recordset to the datagrid
          here's an example
          Here Myrs2 is the record set
          'Set on the cursor location
          MyRs2.CursorLoc ation = adUseClient
          MyRs2.Open "select * from investmentdetai ls ", MyCon, adOpenDynamic, adLockOptimisti c
          'Set the datasource to the record set
          Set DataGrid1.DataS ource = MyRs2

          NEXT TIME ONWARDS PLEASE PUT ON YOUR CODE

          Good luck
          I dont want to display records from a perticular table. I want to enter records by my own into Data Grid at runtime. So what is the solution for that?

          Comment

          • cmrhema
            Contributor
            • Jan 2007
            • 375

            #6
            Originally posted by Shailja
            I dont want to display records from a perticular table. I want to enter records by my own into Data Grid at runtime. So what is the solution for that?
            DID U TRY OUT THE CODE

            'Set on the cursor location
            MyRs2.CursorLoc ation = adUseClient
            MyRs2.Open "select * from investmentdetai ls ", MyCon, adOpenDynamic, adLockOptimisti c
            'Set the datasource to the record set
            Set DataGrid1.DataS ource = MyRs2
            NOW YOU WILL BE ABLE TO ENTER DATA.
            Make sure to set AllowAddNew and AllowUpdate to true
            No need any more code it will automatically add the records In case you want to delete set AllowDelete to true

            Comment

            • Shailja
              New Member
              • Feb 2007
              • 123

              #7
              Originally posted by cmrhema
              DID U TRY OUT THE CODE

              'Set on the cursor location
              MyRs2.CursorLoc ation = adUseClient
              MyRs2.Open "select * from investmentdetai ls ", MyCon, adOpenDynamic, adLockOptimisti c
              'Set the datasource to the record set
              Set DataGrid1.DataS ource = MyRs2
              NOW YOU WILL BE ABLE TO ENTER DATA.
              Make sure to set AllowAddNew and AllowUpdate to true
              No need any more code it will automatically add the records In case you want to delete set AllowDelete to true

              No, Still i am not able to enter new record in data grid. You dont understand my question. I dont want to display records of perticular table in grid. I want to add records in grid at runtime. Grid will be blank at runtime and i want to enter data in it. Neither cursor is coming in first column and first row nor i m able to enter the record

              Comment

              • coolminded
                New Member
                • Mar 2007
                • 137

                #8
                you can better use the component 'VSFlex' to write at the run time

                Comment

                • Shailja
                  New Member
                  • Feb 2007
                  • 123

                  #9
                  Originally posted by coolminded
                  you can better use the component 'VSFlex' to write at the run time
                  I dont understand ur reply. you have asked me to use FlexGrid? But in MSFlex Grid i wont be able to edit cell, right?

                  How to enter data in that at runtime? Plz let me know

                  Comment

                  • vijaydiwakar
                    Contributor
                    • Feb 2007
                    • 579

                    #10
                    Originally posted by Shailja
                    I dont understand ur reply. you have asked me to use FlexGrid? But in MSFlex Grid i wont be able to edit cell, right?

                    How to enter data in that at runtime? Plz let me know
                    Shailja ,
                    MSFlexgrid is not editable.
                    That's y i had suggested u to use Componant One's VsFlexGrid
                    Try It
                    Good Luck

                    Comment

                    • Shailja
                      New Member
                      • Feb 2007
                      • 123

                      #11
                      Originally posted by vijaydiwakar
                      Shailja ,
                      MSFlexgrid is not editable.
                      That's y i had suggested u to use Componant One's VsFlexGrid
                      Try It
                      Good Luck
                      Thanks for the reply.Can u tell me how to add that component? I have never used it. How to add it and what code should i write to enter data at runtime?

                      Comment

                      • vijaydiwakar
                        Contributor
                        • Feb 2007
                        • 579

                        #12
                        Originally posted by Shailja
                        Thanks for the reply.Can u tell me how to add that component? I have never used it. How to add it and what code should i write to enter data at runtime?
                        See this is the third part componant.
                        So u have to manage it by urself.
                        for run time editing no need to code any more its by default editable i.e. u've to set its editable property =0 or 1 or 2 or 3
                        try it Good Luck

                        Comment

                        • cmrhema
                          Contributor
                          • Jan 2007
                          • 375

                          #13
                          Originally posted by vijaydiwakar
                          See this is the third part componant.
                          So u have to manage it by urself.
                          for run time editing no need to code any more its by default editable i.e. u've to set its editable property =0 or 1 or 2 or 3
                          try it Good Luck
                          Shailja
                          Kindly let me know one thing. Are u connecting datagrid with ADODC control or are you using ADODB.
                          In case you are using ADODB I am at complete loss to understand why and where did my code fail in entering data.
                          I not only completed my project using that code. But got installed at the client's place with much success.

                          Comment

                          • Shailja
                            New Member
                            • Feb 2007
                            • 123

                            #14
                            Originally posted by vijaydiwakar
                            See this is the third part componant.
                            So u have to manage it by urself.
                            for run time editing no need to code any more its by default editable i.e. u've to set its editable property =0 or 1 or 2 or 3
                            try it Good Luck

                            How do i get the component? From which site, i will get that component? Can u suggest me site? Bcoz VB does not provide that component.

                            Comment

                            • Shailja
                              New Member
                              • Feb 2007
                              • 123

                              #15
                              Originally posted by cmrhema
                              Shailja
                              Kindly let me know one thing. Are u connecting datagrid with ADODC control or are you using ADODB.
                              In case you are using ADODB I am at complete loss to understand why and where did my code fail in entering data.
                              I not only completed my project using that code. But got installed at the client's place with much success.
                              I am using ADODB. Why I need to connect datagrid as i dont want to display records from perticular table. I want to enter by my own. Is it possible with datagrid or not?

                              Comment

                              Working...