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. table to label - basics(asp&c#)

table to label - basics(asp&c#)

Scheduled Pinned Locked Moved C#
questioncsharphelp
4 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.
  • L Offline
    L Offline
    locaas
    wrote on last edited by
    #1

    1.I have a table(with 1 row) and i whant do create as many labels as columns. Each label has to have the text equal to a column name and the position: x:24 for everyone and label1 y = 60 label2 y = 120 label3 y= 180 and so on. All this has to be made throw c# code. 2. How do i put the text from a textbox in a table? PLZ HELP

    P 1 Reply Last reply
    0
    • L locaas

      1.I have a table(with 1 row) and i whant do create as many labels as columns. Each label has to have the text equal to a column name and the position: x:24 for everyone and label1 y = 60 label2 y = 120 label3 y= 180 and so on. All this has to be made throw c# code. 2. How do i put the text from a textbox in a table? PLZ HELP

      P Offline
      P Offline
      pq4noeh
      wrote on last edited by
      #2

      what do you mean with table a dataTable object or a database table? If it is a database witch kind of database and how do you connect with it? anyway. you can get the label property text and with it do and update if it is database table: "alter table 'tablename' add column (label.text.toUpper() datatipe(length))" if you are talking about a datatable is even easier datatablename.columns.add("label.text"); hopefully it will help you NOthing by now;)

      L 1 Reply Last reply
      0
      • P pq4noeh

        what do you mean with table a dataTable object or a database table? If it is a database witch kind of database and how do you connect with it? anyway. you can get the label property text and with it do and update if it is database table: "alter table 'tablename' add column (label.text.toUpper() datatipe(length))" if you are talking about a datatable is even easier datatablename.columns.add("label.text"); hopefully it will help you NOthing by now;)

        L Offline
        L Offline
        locaas
        wrote on last edited by
        #3

        10x table object. but how do i create as many labels as column whit the propety label1.text equal to evry column name. ex: label1.text = the name of the first column from the table. can anyone write the code for this.

        P 1 Reply Last reply
        0
        • L locaas

          10x table object. but how do i create as many labels as column whit the propety label1.text equal to evry column name. ex: label1.text = the name of the first column from the table. can anyone write the code for this.

          P Offline
          P Offline
          pq4noeh
          wrote on last edited by
          #4

          //i have not tryed the code so it might have some errors but i think you can get the idea //SQL_COMMANDS (this commands will work only if you have a SQL Database) //this command will return all the non system tables SELECT Table_Name AS NOMBRE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE ' //this will return all the column names from a given database and table SELECT COLUMN_NAME as column FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME string Query = "SELECT COLUMN_NAME as column FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME LIKE 'the_name_of_your_table' //first you have to get all the column names of your table Cache = new System.Data.DataSet(); using (SqlConnection Conn = new SqlConnection(this.Conexion)) { SqlDataAdapter SqlDs = new SqlDataAdapter(Query,Conn); Conn.Open(); SqlDs.Fill(Cache,NombreTabla); } //now you have all the column names and you have to iterate as many times as columns you have creating and adding to your form a lavel //note that in your case the location will have to be assign dinamicly foreah(DataRow row in Cache.DataTable["NombreTabla"].rows) { System.Windows.Forms.Label MyLabel = new System.Windows.Forms.Label(); MyLabel .Location = new System.Drawing.Point(64, 64); MyLabel .Name = row[0].tostring(); MyLabel .Size = new System.Drawing.Size(376, 64); MyLabel .TabIndex = 0; MyLabel .Text = row[0].tostring(); //here we add the new label to the form this.controls.add(MyLabel) } //i hope the code above can help you NOthing by now;)

          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