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. Visual Basic
  4. IListSource Implementation

IListSource Implementation

Scheduled Pinned Locked Moved Visual Basic
csstutorialquestion
8 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.
  • O Offline
    O Offline
    Ovais Memon
    wrote on last edited by
    #1

    Hi All, I have made a project in VB2008 in which I have bind my Grid to Class as a datasource. The column names of Grid are the property names of the class. But I need to have customize column names for my properties in the Grid. One way is to add an attribute _ for example before each property. But it is so hard to name each and every property as i have thousands of properties in this project. Someone has told me that there is a way by using IListSource.. Does anyone have any idea about that?? Regards Ovais

    D M 2 Replies Last reply
    0
    • O Ovais Memon

      Hi All, I have made a project in VB2008 in which I have bind my Grid to Class as a datasource. The column names of Grid are the property names of the class. But I need to have customize column names for my properties in the Grid. One way is to add an attribute _ for example before each property. But it is so hard to name each and every property as i have thousands of properties in this project. Someone has told me that there is a way by using IListSource.. Does anyone have any idea about that?? Regards Ovais

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

      You could just create the columns in the grid yourself, then just setup the bindings for each column to property yourself.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008
      But no longer in 2009...

      O 1 Reply Last reply
      0
      • D Dave Kreskowiak

        You could just create the columns in the grid yourself, then just setup the bindings for each column to property yourself.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008
        But no longer in 2009...

        O Offline
        O Offline
        Ovais Memon
        wrote on last edited by
        #3

        Thanks for your reply dear, but I have only one grid which is binded by different classes at different scenarios.. For e.g. Instead of having separate grids for Employees, Leaves, Allowances, Deductions (to show thier respective detail), i've a single grid. When i hit Employees button, it fills with Employees class, when i hit Leaves button, it fills with Leave class, and so forth.. Hope you understand my problem. Ovais

        H D 2 Replies Last reply
        0
        • O Ovais Memon

          Thanks for your reply dear, but I have only one grid which is binded by different classes at different scenarios.. For e.g. Instead of having separate grids for Employees, Leaves, Allowances, Deductions (to show thier respective detail), i've a single grid. When i hit Employees button, it fills with Employees class, when i hit Leaves button, it fills with Leave class, and so forth.. Hope you understand my problem. Ovais

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          Ovais Memon wrote:

          Instead of having separate grids for Employees, Leaves, Allowances, Deductions (to show thier respective detail), i've a single grid. When i hit Employees button, it fills with Employees class, when i hit Leaves button, it fills with Leave class, and so forth..

          Then if you are able to, I would suggest that you have a Form for each category. Apart from this allowing you to do as previously suggested for the column binding, it will enable your users to do side-by-side comparisons between datasets.

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          1 Reply Last reply
          0
          • O Ovais Memon

            Thanks for your reply dear, but I have only one grid which is binded by different classes at different scenarios.. For e.g. Instead of having separate grids for Employees, Leaves, Allowances, Deductions (to show thier respective detail), i've a single grid. When i hit Employees button, it fills with Employees class, when i hit Leaves button, it fills with Leave class, and so forth.. Hope you understand my problem. Ovais

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

            So what's stopping you from Clearing the Columns collection and creating a new set of columns in the same grid and binding those to the new object collection?

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007, 2008
            But no longer in 2009...

            O 1 Reply Last reply
            0
            • D Dave Kreskowiak

              So what's stopping you from Clearing the Columns collection and creating a new set of columns in the same grid and binding those to the new object collection?

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007, 2008
              But no longer in 2009...

              O Offline
              O Offline
              Ovais Memon
              wrote on last edited by
              #6

              Thats what i was doing so far, but the problem is that i m unable to customize column names in the grid. Acc. to your suggestion, i suppose to name the columns for each class at the time of binding with the grid..

              D 1 Reply Last reply
              0
              • O Ovais Memon

                Thats what i was doing so far, but the problem is that i m unable to customize column names in the grid. Acc. to your suggestion, i suppose to name the columns for each class at the time of binding with the grid..

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

                Each DataGridViewColumn derivative allows you to set the columnheader text, using it's HeaderText property, seperately from the column name it's bound to.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                     2006, 2007, 2008
                But no longer in 2009...

                1 Reply Last reply
                0
                • O Ovais Memon

                  Hi All, I have made a project in VB2008 in which I have bind my Grid to Class as a datasource. The column names of Grid are the property names of the class. But I need to have customize column names for my properties in the Grid. One way is to add an attribute _ for example before each property. But it is so hard to name each and every property as i have thousands of properties in this project. Someone has told me that there is a way by using IListSource.. Does anyone have any idea about that?? Regards Ovais

                  M Offline
                  M Offline
                  Mycroft Holmes
                  wrote on last edited by
                  #8

                  I do exactly the same in my main form, 1 DGV and throw tables at it. I have a static method that formats names according to the capitilasition eg "ContactID" becomes "Contact ID" and I use this to populate the header text, it is part of a method that is used to bind all DGVs and gives me a consistent format throughout the app. It also means you need to take your conventions all the way back to the database design. As I own the DB I have no problem with this. My problem is that if you bind to the List using the public properties you lose the sort/filter capabilities unless you implement iBindingList (I think) on each of your classes which is a PITA. So Ah Ha I though, turn each class into a datatable, at which point I chucked the entire bind to class list out and just bind to the original datatable.

                  Never underestimate the power of human stupidity RAH

                  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