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. Dataset TableNewRow Event [solved]

Dataset TableNewRow Event [solved]

Scheduled Pinned Locked Moved C#
csharpquestion
8 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.
  • M Offline
    M Offline
    Midnight Ahri
    wrote on last edited by
    #1

    i'm new in C#, whenever i'm going to create an event sub in vb.net, i choose event inside two combobox below page tab, but in C# it's totally different. then i figure it out by double clicking event properties, the sub will pop out in the code page. nah this time, it's about dataset (datatable) event, both method above isn't working. i've tried code converter and the output is "handles clauses are not supported in C#" any suggestion? uh and also, what's inside two combobox below page tab in C#? :doh:

    OriginalGriffO 1 Reply Last reply
    0
    • M Midnight Ahri

      i'm new in C#, whenever i'm going to create an event sub in vb.net, i choose event inside two combobox below page tab, but in C# it's totally different. then i figure it out by double clicking event properties, the sub will pop out in the code page. nah this time, it's about dataset (datatable) event, both method above isn't working. i've tried code converter and the output is "handles clauses are not supported in C#" any suggestion? uh and also, what's inside two combobox below page tab in C#? :doh:

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      The two combo boxes are easy - the left is all the classes in the current file - click on one and it will take you to the start of the definition. On the right are all the objects in the class - again, click to go to definition. The event adding in C# is the same for DataSet object (you can't add DataTables directly in the designer, so they are irrelevant here). Highlight the dataset, and look at the Properties pane. Click on the Lightning Bolt button to switch to the Events view, and double click the event - there are only three for a dataset anyway, and it it unlikely that you would want to handle any of them as a beginner in C# - Disposed, Initialized and MergeFailed are events I've not needed to override yet! :laugh: To add event handlers for a DataTable, you have to add it to the DataSet via it's Tables property, then select the table in the Property pane Objects drop down list. You can then access the events via the Lightening bolt button as before.

      Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      M 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        The two combo boxes are easy - the left is all the classes in the current file - click on one and it will take you to the start of the definition. On the right are all the objects in the class - again, click to go to definition. The event adding in C# is the same for DataSet object (you can't add DataTables directly in the designer, so they are irrelevant here). Highlight the dataset, and look at the Properties pane. Click on the Lightning Bolt button to switch to the Events view, and double click the event - there are only three for a dataset anyway, and it it unlikely that you would want to handle any of them as a beginner in C# - Disposed, Initialized and MergeFailed are events I've not needed to override yet! :laugh: To add event handlers for a DataTable, you have to add it to the DataSet via it's Tables property, then select the table in the Property pane Objects drop down list. You can then access the events via the Lightening bolt button as before.

        Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

        M Offline
        M Offline
        Midnight Ahri
        wrote on last edited by
        #3

        yes, from the first time i'm confused of these two combobox in C#, i've use that lightning bolt (event) properties. the problem is, in dataset or even when i clicked datatable, there's no lightning bolt in properties page. :doh:

        OriginalGriffO 1 Reply Last reply
        0
        • M Midnight Ahri

          yes, from the first time i'm confused of these two combobox in C#, i've use that lightning bolt (event) properties. the problem is, in dataset or even when i clicked datatable, there's no lightning bolt in properties page. :doh:

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          The properties page is only relevant in the designer - not in the code window, if that's where you are clicking. You can't click a DataTable in the designer window directly - it doesn't have any UI element, so I assume you are highlighting the DataTable in the code window and trying to add an event? If so, then just on a new line in your code, type the name of the DataTable instance and press "." Intellisense will pop up a list of objects - select the event you want to add a handler for and type "+="

          myDataTable.ColumnChanged+=

          Intellisense will pop up a handler helper box:

          new DataColumnChangeEventHandler(dt_ColumnChanged); (Press TAB to insert)

          Press Tab to insert the text, and another box will appear:

          Press TAB to generate Handler "dt_ColumnChanged" in this class

          If you press Tab again, it will create a handler method stub for you to complete. Once you have the basic code, you can modify or tweak it to fit what you want to do !

          Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          M 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            The properties page is only relevant in the designer - not in the code window, if that's where you are clicking. You can't click a DataTable in the designer window directly - it doesn't have any UI element, so I assume you are highlighting the DataTable in the code window and trying to add an event? If so, then just on a new line in your code, type the name of the DataTable instance and press "." Intellisense will pop up a list of objects - select the event you want to add a handler for and type "+="

            myDataTable.ColumnChanged+=

            Intellisense will pop up a handler helper box:

            new DataColumnChangeEventHandler(dt_ColumnChanged); (Press TAB to insert)

            Press Tab to insert the text, and another box will appear:

            Press TAB to generate Handler "dt_ColumnChanged" in this class

            If you press Tab again, it will create a handler method stub for you to complete. Once you have the basic code, you can modify or tweak it to fit what you want to do !

            Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

            M Offline
            M Offline
            Midnight Ahri
            wrote on last edited by
            #5

            namespace Documents.Objects.Datasets
            {
            public partial class dsDocuments
            {
            BooksDataTable. //even ctrl + space didn't work
            }
            }

            pardon me, i'm not really sure where to put the code, inside datatable class or dataset class, but wherever i put "BooksDataTable.", no intellisense is available. sorry i'm not used to C#, i'd be glad if you give me more information of this. ;P

            OriginalGriffO 1 Reply Last reply
            0
            • M Midnight Ahri

              namespace Documents.Objects.Datasets
              {
              public partial class dsDocuments
              {
              BooksDataTable. //even ctrl + space didn't work
              }
              }

              pardon me, i'm not really sure where to put the code, inside datatable class or dataset class, but wherever i put "BooksDataTable.", no intellisense is available. sorry i'm not used to C#, i'd be glad if you give me more information of this. ;P

              OriginalGriffO Offline
              OriginalGriffO Offline
              OriginalGriff
              wrote on last edited by
              #6

              Inside a method:

              private DataTable BooksDataTable = new DataTable();
              private void AddHandlers()
              {
              BooksDataTable.ColumnChanged += new DataColumnChangeEventHandler(BooksDataTable_ColumnChanged);
              }

              void BooksDataTable_ColumnChanged(object sender, DataColumnChangeEventArgs e)
              {
              throw new NotImplementedException();
              }

              Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              M 1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                Inside a method:

                private DataTable BooksDataTable = new DataTable();
                private void AddHandlers()
                {
                BooksDataTable.ColumnChanged += new DataColumnChangeEventHandler(BooksDataTable_ColumnChanged);
                }

                void BooksDataTable_ColumnChanged(object sender, DataColumnChangeEventArgs e)
                {
                throw new NotImplementedException();
                }

                Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

                M Offline
                M Offline
                Midnight Ahri
                wrote on last edited by
                #7

                thank you very much, i get it now. :laugh:

                OriginalGriffO 1 Reply Last reply
                0
                • M Midnight Ahri

                  thank you very much, i get it now. :laugh:

                  OriginalGriffO Offline
                  OriginalGriffO Offline
                  OriginalGriff
                  wrote on last edited by
                  #8

                  Yes, of course! All you have to do is add the appropriate code to the DataTables in the DataSet.Tables property.

                  Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                  "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                  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