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. Newline in constant error

Newline in constant error

Scheduled Pinned Locked Moved C#
helpquestion
9 Posts 4 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.
  • V Offline
    V Offline
    vcorn
    wrote on last edited by
    #1

    hi, anyone know about that kind of error? Thanks

    D T 2 Replies Last reply
    0
    • V vcorn

      hi, anyone know about that kind of error? Thanks

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      It would help if you posted the code where the error occurs! RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      V 1 Reply Last reply
      0
      • D Dave Kreskowiak

        It would help if you posted the code where the error occurs! RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        V Offline
        V Offline
        vcorn
        wrote on last edited by
        #3

        Thanks David, i close the Visual Studio and reopen, everything's just fine then, sounds weird though.. Thanks But i have another question, i wanna apply column style to one of the columns in my table, i wanna hide one column but setting its width to zero, i have five datacolumn object, but i only have one gridcolumnstyle with mapping name set to one of the column name i wanna hide. but the style doesn't apply, the column is not hidden. how am i goin to hide it?

        D 1 Reply Last reply
        0
        • V vcorn

          Thanks David, i close the Visual Studio and reopen, everything's just fine then, sounds weird though.. Thanks But i have another question, i wanna apply column style to one of the columns in my table, i wanna hide one column but setting its width to zero, i have five datacolumn object, but i only have one gridcolumnstyle with mapping name set to one of the column name i wanna hide. but the style doesn't apply, the column is not hidden. how am i goin to hide it?

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          You hide the column by setting it's width to 0, but since you haven't supplied any code, I can't tell you what your doing wrong. So, here's an example:

          private void HideColumnOfDataSet()
          {
          System.Data.DataTable points = new System.Data.DataTable("Points");
          points.Columns.Add(new DataColumn("X", typeof(int)));
          points.Columns.Add(new DataColumn("Y", typeof(int)));
          points.Rows.Add(new object[]{1, 2});
          points.Rows.Add(new object[]{3, 5});
          dataGrid1.DataSource = points;
           
          DataGridTableStyle tableStyle = new DataGridTableStyle();
          tableStyle.MappingName = "Points";
          dataGrid1.TableStyles.Add(tableStyle);
          dataGrid1.TableStyles["Points"].GridColumnStyles["X"].Width = 0;

          }

          RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          V 1 Reply Last reply
          0
          • D Dave Kreskowiak

            You hide the column by setting it's width to 0, but since you haven't supplied any code, I can't tell you what your doing wrong. So, here's an example:

            private void HideColumnOfDataSet()
            {
            System.Data.DataTable points = new System.Data.DataTable("Points");
            points.Columns.Add(new DataColumn("X", typeof(int)));
            points.Columns.Add(new DataColumn("Y", typeof(int)));
            points.Rows.Add(new object[]{1, 2});
            points.Rows.Add(new object[]{3, 5});
            dataGrid1.DataSource = points;
             
            DataGridTableStyle tableStyle = new DataGridTableStyle();
            tableStyle.MappingName = "Points";
            dataGrid1.TableStyles.Add(tableStyle);
            dataGrid1.TableStyles["Points"].GridColumnStyles["X"].Width = 0;

            }

            RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            V Offline
            V Offline
            vcorn
            wrote on last edited by
            #5

            i get null reference exception in this line this.dataGrid1.TableStyles["Students"].GridColumnStyles["Password"].Width = 0; how?

            D H 2 Replies Last reply
            0
            • V vcorn

              i get null reference exception in this line this.dataGrid1.TableStyles["Students"].GridColumnStyles["Password"].Width = 0; how?

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              I can't tell without seeing the rest of your code in that block. Most likely, you're missing a 'new' somewhere. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              V 1 Reply Last reply
              0
              • D Dave Kreskowiak

                I can't tell without seeing the rest of your code in that block. Most likely, you're missing a 'new' somewhere. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                V Offline
                V Offline
                vcorn
                wrote on last edited by
                #7

                Thanks Dave, found it, i did it inside the initialize component(using designer) and indeed the designer define the table style before adding column. i replace the order, add column first, then it's fine. Thanks:)

                1 Reply Last reply
                0
                • V vcorn

                  i get null reference exception in this line this.dataGrid1.TableStyles["Students"].GridColumnStyles["Password"].Width = 0; how?

                  H Offline
                  H Offline
                  Heath Stewart
                  wrote on last edited by
                  #8

                  Accessing indexes requires that an object at that index (or with that index keyword, like the table style or column style name above) exists. If it doesn't, null is returned from the index property. When you try to call a method or access a property on null, you get a NullReferenceException.

                  Microsoft MVP, Visual C# My Articles

                  1 Reply Last reply
                  0
                  • V vcorn

                    hi, anyone know about that kind of error? Thanks

                    T Offline
                    T Offline
                    the last free name
                    wrote on last edited by
                    #9

                    I sometimes see it in a perfectly valid line of code. I simply cut and re-paste the line and the compiler is then happy!

                    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