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. Custom Columheader

Custom Columheader

Scheduled Pinned Locked Moved Visual Basic
databasequestion
10 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.
  • O Offline
    O Offline
    Ole123
    wrote on last edited by
    #1

    How do you pull data from a database and set them as columnheader in listview or a datagrid?:((

    S 1 Reply Last reply
    0
    • O Ole123

      How do you pull data from a database and set them as columnheader in listview or a datagrid?:((

      S Offline
      S Offline
      superwinsock
      wrote on last edited by
      #2

      Are you using a stored procedure? Give more info about your requirements... Later

      O 1 Reply Last reply
      0
      • S superwinsock

        Are you using a stored procedure? Give more info about your requirements... Later

        O Offline
        O Offline
        Ole123
        wrote on last edited by
        #3

        Student_Name Teacher_Namer Subject Time Date James Keith Prof. Clark Math 9:00am 01/05/2004 James Keith Prof. Moore English 10:00am 01/05/2004 James Keith Prof. Smith Art 11:00am 01/05/2004 James Keith Prof. James P.E 1:00pm 01/05/2004 James Keith Prof. Brooke Chem 2:00pm 01/05/2004 James Keith Prof. Daniels Math 3:00pm 01/05/2004 Peter Robertson Prof. Clark Math 8:00am 01/05/2004 Peter Robertson Prof. Moore English 12:00am 01/05/2004 Peter Robertson Prof. Smith Art 4:00pm 01/05/2004 Peter Robertson Prof. James P.E 5:00pm 01/05/2004 Peter Robertson Prof. Brooke Chem 6:00pm 01/05/2004 Peter Robertson Prof. Daniels Math 7:00pm 01/05/2004 Teachers + Prof. Clark + Prof. Brooke + Prof. Daniels +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Time +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 8:00 + Peter Robertson + + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 9:00 + James Keith + + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 10:00 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 11:00 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 12:00 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1:00 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2:00 + + James Keith +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ The list view will be controlled by a date or calendar control. Haven’t decided whether to use a stored procedure. Since I use a select statement with a case argument. Still not getting the look I want. It would be similar to a cross tab table used in ms access. Teachers Prof. Clark Prof. Brooke Prof. Daniels Time

        S 1 Reply Last reply
        0
        • O Ole123

          Student_Name Teacher_Namer Subject Time Date James Keith Prof. Clark Math 9:00am 01/05/2004 James Keith Prof. Moore English 10:00am 01/05/2004 James Keith Prof. Smith Art 11:00am 01/05/2004 James Keith Prof. James P.E 1:00pm 01/05/2004 James Keith Prof. Brooke Chem 2:00pm 01/05/2004 James Keith Prof. Daniels Math 3:00pm 01/05/2004 Peter Robertson Prof. Clark Math 8:00am 01/05/2004 Peter Robertson Prof. Moore English 12:00am 01/05/2004 Peter Robertson Prof. Smith Art 4:00pm 01/05/2004 Peter Robertson Prof. James P.E 5:00pm 01/05/2004 Peter Robertson Prof. Brooke Chem 6:00pm 01/05/2004 Peter Robertson Prof. Daniels Math 7:00pm 01/05/2004 Teachers + Prof. Clark + Prof. Brooke + Prof. Daniels +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Time +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 8:00 + Peter Robertson + + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 9:00 + James Keith + + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 10:00 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 11:00 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 12:00 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1:00 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2:00 + + James Keith +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ The list view will be controlled by a date or calendar control. Haven’t decided whether to use a stored procedure. Since I use a select statement with a case argument. Still not getting the look I want. It would be similar to a cross tab table used in ms access. Teachers Prof. Clark Prof. Brooke Prof. Daniels Time

          S Offline
          S Offline
          superwinsock
          wrote on last edited by
          #4

          Hey Ole123 Well I will leave the front end to you, but if you choose to go with a stored proc then here is the basic layout including getting the headers... CREATE PROCEDURE MP_CB_Get_CallBacks AS -- V1.0.0 : Super Winsock : 4 March 2002 -- Returns the Column names and width for the grid. -- It also returns the data. SET NOCOUNT ON --Returns the Column names and it's width. -- 1st is the column name & 2nd is the column width and so on. SELECT 'Id', 0, 'Student_Name', 0, 'Teacher_Name', 2000, 'Subject', 1500, 'Time', 1500, 'Date', 1500 SELECT [Id], Student_Name, Teacher_Name, Subject, Time, Date FROM ?Table SET NOCOUNT OFF GO /* Hope this helps?

          O 1 Reply Last reply
          0
          • S superwinsock

            Hey Ole123 Well I will leave the front end to you, but if you choose to go with a stored proc then here is the basic layout including getting the headers... CREATE PROCEDURE MP_CB_Get_CallBacks AS -- V1.0.0 : Super Winsock : 4 March 2002 -- Returns the Column names and width for the grid. -- It also returns the data. SET NOCOUNT ON --Returns the Column names and it's width. -- 1st is the column name & 2nd is the column width and so on. SELECT 'Id', 0, 'Student_Name', 0, 'Teacher_Name', 2000, 'Subject', 1500, 'Time', 1500, 'Date', 1500 SELECT [Id], Student_Name, Teacher_Name, Subject, Time, Date FROM ?Table SET NOCOUNT OFF GO /* Hope this helps?

            O Offline
            O Offline
            Ole123
            wrote on last edited by
            #5

            I forgot to add that the student data is a seperate table as well as the teacher's data. So I have a Student and Teacher table. I don't think I could use a stored procedure.

            S 1 Reply Last reply
            0
            • O Ole123

              I forgot to add that the student data is a seperate table as well as the teacher's data. So I have a Student and Teacher table. I don't think I could use a stored procedure.

              S Offline
              S Offline
              superwinsock
              wrote on last edited by
              #6

              Well thats no problem?? Just use a JOIN statement to join the teacher and Student tables... This can be done in a sproc. If you really get stuck, just post the Student and Teacher Tables structures and what you want to get out of them in your record set, and I will gladly help you write the sproc. Later Cliff

              O 2 Replies Last reply
              0
              • S superwinsock

                Well thats no problem?? Just use a JOIN statement to join the teacher and Student tables... This can be done in a sproc. If you really get stuck, just post the Student and Teacher Tables structures and what you want to get out of them in your record set, and I will gladly help you write the sproc. Later Cliff

                O Offline
                O Offline
                Ole123
                wrote on last edited by
                #7

                Student_ID | Student_Lname | Student Fname | Subject ID | ---------------------------------------------------------------------- 125 | Mason | Steven | 2 | 100 | Jude | Bob | 2 | 199 | Mason | Mark | 2 | 125 | Mason | Steven | 4 | 225 | Stevenson | John | 2 | 125 | Mason | Steven | 5 | 400 | Madison | Ira | 2 | Teacher_ID | Teacher_Lname | Teacher_Fname | Subject ID | Subject Name| Date | Time| ------------------------------------------------------------------------------------------------------------ 1 | Mason | Steven | 2 | Math | 1/1/2004 | 11:00 am 2 | long | Gary | 2 | English|| 1/1/2004 | 1:00 pm 3 | Clark | James | 2 | P.E| 1/1/2004 | 11:00 am 4 | Simmons | Micheal | 4 | Science| 1/1/2004 | 11:00 pm 5 | Bonnila | Richard | 2 |Art | 1/1/2004 | 11:00 am 6 | Law | Katherine | 5 |Social Studies| 1/1/2004 | 9:00 am 7 | Young | David | 2 | Econ| 1/1/2004 | 8:00 am It should be displayed in the list view as Teachers |Prof. Clark | Prof. Brooke | Prof. Daniels ___________________________________________ Time ____________________________________________ 8:00 | Peter Robertson | Blank|Blank ____________________________________________ 9:00 |James Keith | Blank|Blank ____________________________________________ 10:00| Blank|Blank| Blank ____________________________________________ 11:00| Blank|Blank| Blank ____________________________________________ 12:00| Blank|Blank| Blank ____________________________________________ 1:00| Blank|Blank| Blank ____________________________________________ 2:00 | Blank|Blank| James Keith ____________________________________________

                1 Reply Last reply
                0
                • S superwinsock

                  Well thats no problem?? Just use a JOIN statement to join the teacher and Student tables... This can be done in a sproc. If you really get stuck, just post the Student and Teacher Tables structures and what you want to get out of them in your record set, and I will gladly help you write the sproc. Later Cliff

                  O Offline
                  O Offline
                  Ole123
                  wrote on last edited by
                  #8

                  Still a little stuck so i still need help. I posted a sample tables in the post and what the display should look like... Thanks for all your help. I have been kicking my self for about two weeks trying to get the display i want with no success. MSSql does not use the Transform sytnax so i'm not able to create the crosstab look and feel for my listview form in vb.net. Thanks again for all your help:)

                  S 1 Reply Last reply
                  0
                  • O Ole123

                    Still a little stuck so i still need help. I posted a sample tables in the post and what the display should look like... Thanks for all your help. I have been kicking my self for about two weeks trying to get the display i want with no success. MSSql does not use the Transform sytnax so i'm not able to create the crosstab look and feel for my listview form in vb.net. Thanks again for all your help:)

                    S Offline
                    S Offline
                    superwinsock
                    wrote on last edited by
                    #9

                    Hey Ole Well your post of the tables is somewhat confusing Teachers |Prof. Clark | Prof. Brooke | Prof. Daniels ___________________________________________ Time ____________________________________________ 8:00 | Peter Robertson | Blank|Blank ____________________________________________ 9:00 |James Keith | Blank|Blank etc... 1.Are your headers always going to be the same? If so then you can just hard code them. 2. Just tell me what the headers are and from there I can get the info from the tables. 3. In a listbox you have to use COURIER NEW as your font, else the spacing is never going to be right. 4. You have to pre-determine your column lengths before you populate the listbox. IE: If you have a column named First_Name, thats 10 characters, and the name is Ole. You will have to add 7 spaces after the name to make the next column's data in line with its header. Probably a bit confusing the way I explained but just tell me the column headers and I will write the sproc. Thats the easy part. You will have to do the front end. Later Cliff

                    O 1 Reply Last reply
                    0
                    • S superwinsock

                      Hey Ole Well your post of the tables is somewhat confusing Teachers |Prof. Clark | Prof. Brooke | Prof. Daniels ___________________________________________ Time ____________________________________________ 8:00 | Peter Robertson | Blank|Blank ____________________________________________ 9:00 |James Keith | Blank|Blank etc... 1.Are your headers always going to be the same? If so then you can just hard code them. 2. Just tell me what the headers are and from there I can get the info from the tables. 3. In a listbox you have to use COURIER NEW as your font, else the spacing is never going to be right. 4. You have to pre-determine your column lengths before you populate the listbox. IE: If you have a column named First_Name, thats 10 characters, and the name is Ole. You will have to add 7 spaces after the name to make the next column's data in line with its header. Probably a bit confusing the way I explained but just tell me the column headers and I will write the sproc. Thats the easy part. You will have to do the front end. Later Cliff

                      O Offline
                      O Offline
                      Ole123
                      wrote on last edited by
                      #10

                      The columnheader will always change. So it's more of a dynamic columnheader. Depending on the Day of the week. There could be 5 or 3 or 10 teacher who have classes to teacher at different time of the day. The Teacher's name will be the columnheader Basically i'm trying to build a cross-tab query Teaher's names across the top The time is in the left column down and student name Teacher_Name Teacher_Name Teacher_Name Teacher_Name Time Student_Name Student_Name Student_Name Student_Name C1 and R2 = Student_Name C2 and R2 = Student_Name C1 and R3 = Student_Name C1 and R3 = Student_Name and so on The only way i can build a cross-tab query is in crystal report. ;)

                      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