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. Add checkboxs dynamically in csharp smart device project

Add checkboxs dynamically in csharp smart device project

Scheduled Pinned Locked Moved C#
csharpdatabase
2 Posts 1 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.
  • T Offline
    T Offline
    Tunisien86
    wrote on last edited by
    #1

    Hello, I am developing a GMAO csharp smart device application.I am in the step of adding checkboxs dynamically:

    I have two tables:Travaux (Works in English) and Actions related by the two fields Nature (table Travaux)and typeTravail(Table Actions).If the user enters the number of the work(NBT the pk_Travaux),the system adds a number of checkboxs equal to the steps that should the user follows to accomplish(field step in Actions table).After that,the user has the possibility to check or not the step if he did it.All the traitments will be done dynamically with the database

    My select statement is:

    select Etape from Action where ((Travaux.NBT=textbox1.text) and (Travaux.Nature=Action.TypeTravail))

    Equal of what this select returns,it will add dynamically checkboxs I wait for u suggestions Regards ;) :rose:

    T 1 Reply Last reply
    0
    • T Tunisien86

      Hello, I am developing a GMAO csharp smart device application.I am in the step of adding checkboxs dynamically:

      I have two tables:Travaux (Works in English) and Actions related by the two fields Nature (table Travaux)and typeTravail(Table Actions).If the user enters the number of the work(NBT the pk_Travaux),the system adds a number of checkboxs equal to the steps that should the user follows to accomplish(field step in Actions table).After that,the user has the possibility to check or not the step if he did it.All the traitments will be done dynamically with the database

      My select statement is:

      select Etape from Action where ((Travaux.NBT=textbox1.text) and (Travaux.Nature=Action.TypeTravail))

      Equal of what this select returns,it will add dynamically checkboxs I wait for u suggestions Regards ;) :rose:

      T Offline
      T Offline
      Tunisien86
      wrote on last edited by
      #2

      Hi, After some search,I elaborate this code that still annoying :(( me with some errors:

      private void button1_Click(object sender, EventArgs e)
      {
      //Create the connection
      string wCS = @"Data Source =\Storage Card\ModeDifféré\BaseGmaoLocale.sdf;";
      SqlCeConnection sqlceconn = new SqlCeConnection(wCS);

              //Create the command
              SqlCeCommand command = sqlceconn.CreateCommand();
              command.CommandText = "Select NBT, Nature from Travaux where NBT=@NBT ";
      
              //Add the parameters
              string s1 = textBox1.Text; //store the login name here YOU MUST FILL THIS IN
              SqlCeParameter NBT = new SqlCeParameter("@NBT", SqlDbType.NVarChar);
              NBT.Value = s1;
      
              command.Parameters.Add(NBT);
              //Create the adapter
              SqlCeDataAdapter adapter = new SqlCeDataAdapter(command);
      
              //Create and fill the dataset
              DataSet ds = new DataSet();
      
              try
              {
                  adapter.Fill(ds, "SQL Temp Table");
              }
              catch (Exception ex)
              {
                  MessageBox.Show(ex.Message);
              }
              foreach (DataRow da in adapter)
              { string s = adapter\["Nature"\]; }
      
              if ((ds.Tables.Count > 0) && (ds.Tables\["SQL Temp Table"\] != null))
              {
                  MessageBox.Show("Number of row(s) - " + ds.Tables\["SQL Temp Table"\].Rows.Count);
                  if (ds.Tables\["SQL Temp Table"\].Rows.Count > 0)
                  {
                      MessageBox.Show("Numéro de BT trouvé");
                      SqlCeCommand command1 = sqlceconn.CreateCommand();
                      command1.CommandText = "Select NoEtape, Etape from Travaux where TypeTravail=@typ ";
      
                      //Add the parameters
                      string s2 = textBox1.Text; //store the login name here YOU MUST FILL THIS IN
                      SqlCeParameter Typ = new SqlCeParameter("@Typ", SqlDbType.NVarChar);
                      Typ.Value = s2;
      
                      command1.Parameters.Add(Typ);
                      SqlCeDataAdapter adapt = new SqlCeDataAdapter(command1);
      
                      //Create and fill the dataset
                      DataSet dat = new DataSet();
      
                      try
                      {
                          adapt.Fill(dat, "SQL Temp Table");
                      }
                      catch (Exception ex)
                      {
      
      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