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. Forcing repainting the cell

Forcing repainting the cell

Scheduled Pinned Locked Moved C#
question
14 Posts 3 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.
  • E Ed Poore

    How about DataGrid.InvalidateCell ? ;)


    Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9 Ed

    E Offline
    E Offline
    e_LA
    wrote on last edited by
    #4

    I crated my own class inherited from DataGridViewImageCell. How can I call a method from parent object which is DataGridView? I passed a DataGridView parameter to constructor but when I call grid.InvalidateCell() I have a message "Object refrence not set to an instance of an object"

    1 Reply Last reply
    0
    • C Christian Graus

      If it has an Invalidate method, call it, that forces a repaint of a control.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      E Offline
      E Offline
      e_LA
      wrote on last edited by
      #5

      But DataGridViewImageCell does not have a Invalidate method.

      C 1 Reply Last reply
      0
      • E e_LA

        But DataGridViewImageCell does not have a Invalidate method.

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #6

        Then you probably need to Invalidate the entire grid.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

        E 1 Reply Last reply
        0
        • C Christian Graus

          Then you probably need to Invalidate the entire grid.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

          E Offline
          E Offline
          e_LA
          wrote on last edited by
          #7

          There is a method grid.InvalidateCell however I cannot call it because I have to do it from DataGridViewImageCell level (form my own class). I described the problem above. Thanks for advice.

          1 Reply Last reply
          0
          • E Ed Poore

            How about DataGrid.InvalidateCell ? ;)


            Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9 Ed

            E Offline
            E Offline
            e_LA
            wrote on last edited by
            #8

            I think I am near the solution however how to call a method of grid being on DataGridViewImageCell level?

            E 1 Reply Last reply
            0
            • E e_LA

              I think I am near the solution however how to call a method of grid being on DataGridViewImageCell level?

              E Offline
              E Offline
              Ed Poore
              wrote on last edited by
              #9

              Which methods of the grid. Please elaborate.


              Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9 Ed

              E 1 Reply Last reply
              0
              • E Ed Poore

                Which methods of the grid. Please elaborate.


                Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9 Ed

                E Offline
                E Offline
                e_LA
                wrote on last edited by
                #10

                I created my own classes public class ImageCell : DataGridViewImageCell { public ImageCell(DataGridView grid) { this.grid = grid; } ........ private void animate(object o, EventArgs e) { DataGridView dgv = (DataGridView)grid; dgv.InvalidateCell(this); /// there is an error } } and public class ImageColumn : DataGridViewColumn { public ImageColumn(DataGridView dgv) { this.CellTemplate = new ImageCell(dgv); this.HeaderText = ""; this.Width = 25; this.Resizable = DataGridViewTriState.False; } } In my application when I have DataGridView I just add ImageColumn object as new column passing DataGridView object to the constructor: ImageColumn imgCol = new ImageColumn(m_DataGridView); m_DataGridView.Columns.Add(imgCol); I do not like to pass such a parameter to the constructor. However how to call InvalidateCell in ImageCell class? thanks Ela

                E 1 Reply Last reply
                0
                • E e_LA

                  I created my own classes public class ImageCell : DataGridViewImageCell { public ImageCell(DataGridView grid) { this.grid = grid; } ........ private void animate(object o, EventArgs e) { DataGridView dgv = (DataGridView)grid; dgv.InvalidateCell(this); /// there is an error } } and public class ImageColumn : DataGridViewColumn { public ImageColumn(DataGridView dgv) { this.CellTemplate = new ImageCell(dgv); this.HeaderText = ""; this.Width = 25; this.Resizable = DataGridViewTriState.False; } } In my application when I have DataGridView I just add ImageColumn object as new column passing DataGridView object to the constructor: ImageColumn imgCol = new ImageColumn(m_DataGridView); m_DataGridView.Columns.Add(imgCol); I do not like to pass such a parameter to the constructor. However how to call InvalidateCell in ImageCell class? thanks Ela

                  E Offline
                  E Offline
                  Ed Poore
                  wrote on last edited by
                  #11

                  You should be able to get a reference to the DataGridView from the conveniently named property DataGridView in your class since you inherit from DataGridViewColumn / Cell and both these eventually inherit from DataGridViewElement which has a property which provides a reference to the DataGridView.


                  Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9 Ed

                  E 1 Reply Last reply
                  0
                  • E Ed Poore

                    You should be able to get a reference to the DataGridView from the conveniently named property DataGridView in your class since you inherit from DataGridViewColumn / Cell and both these eventually inherit from DataGridViewElement which has a property which provides a reference to the DataGridView.


                    Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9 Ed

                    E Offline
                    E Offline
                    e_LA
                    wrote on last edited by
                    #12

                    What a fool I am. How couldn't I see such a beatifull protperty - just DataGridView. Many thanks for help. It is blinking now but there is something with gif. It is displayed as x - as it was no gif. However I think it is another problem. Many thanks one more time Ela

                    E 1 Reply Last reply
                    0
                    • E e_LA

                      What a fool I am. How couldn't I see such a beatifull protperty - just DataGridView. Many thanks for help. It is blinking now but there is something with gif. It is displayed as x - as it was no gif. However I think it is another problem. Many thanks one more time Ela

                      E Offline
                      E Offline
                      Ed Poore
                      wrote on last edited by
                      #13

                      Don't worry I had a similar problem where I spent a whole day ripping code apart trying to find the answer and in the end it was looking me in the face :-O The X is probably because it can't find the gif or there was an error in the drawing code (similar to when a control crashes on the designer).


                      Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9 Ed

                      E 1 Reply Last reply
                      0
                      • E Ed Poore

                        Don't worry I had a similar problem where I spent a whole day ripping code apart trying to find the answer and in the end it was looking me in the face :-O The X is probably because it can't find the gif or there was an error in the drawing code (similar to when a control crashes on the designer).


                        Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9 Ed

                        E Offline
                        E Offline
                        e_LA
                        wrote on last edited by
                        #14

                        Such a life of developer :-)

                        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