c# - Match TextBox(es) with Labels -


At runtime, I am interrogating an access table and storing results in an array. So for example, the data structure of that access table is

  Sales Specialname ------ Item 1 Soled ----- Item 2 Soled --------- - Item 3 Sold Mitch Boat Camera Jason Car Shells Mitch Eggs Richard Coffee Bacon Beans  

I want to create a label that is SalespersonName & amp; Make a text box next to the Salesperson name that will show all the blank items the netted field. Then my desired output will be

  (label) Mitch (text box) boat (text box) camera (label) Jason (text box) car (text box) shells (label) mitch (text box ) Egg (label) Richard (text box) Coffee (text box) Bacon (TATB) bean  

I do not understand that the price is not empty only if the value is zero. I am only able to do this for all or something which I am not after that.

Code to add everything below

  string path = "A: \\ Database1 .mdb"; Object oName = path; System.Collections.Hashtable Lookup = New System compilation. Hashtable (); Oledibiconnekshn Olekn = new Oledibiconkekshn ( "Provider = Microsoft. Jeattikoelidibi 4.0; Data Source =" + Onam "); OleconkOpen (); Oledibi Command command = new Oledibi Command (" select * from "Olekn) ; Dr = command.ExecuteReader (); while (dr. Reid ()) {FieldskAdd (Dr. [0] Kostring ());} Dr. Close (); string field Forec (field) {label Lebljh = new label (); Labelz.Name = "labelz_" + index; Labelz.Text = label; Labelz.AutoSize = true; Labelz.Location = new point (10, 30); panel1.Controls.Add (labelz); text Oks textbox = new TextBox (); Textboxes.Name = "txt_" + index; text box. Location = New Point (10, 80); Textboxes.AutoSize = true; PanellkControlskAdd (boxes); if ( fields! = "") {Panel1.SetFlowBreak (text box, true);} index ++;}  

well your code does not add all the components it connects labels with text labels variable text box, I suggest you to split the argument into two parts:

< Ul>
  • Nrcna retrieve data to manipulate and Keep it more comfortable to create a class, which keeps the required data from the database.
  • Use the necessary layout to create components in the data.
  • How can this be done (pseudo code has not been tested):


    First part:

      // data square class person {public string name {get; Set;} public list & lt; String & gt; SoldItems {get; Set;}} // Fill data list & lt; Person & gt; Person = new list & lt; Person & gt; (); Int itemclaimman = 3; While (Dr. Reed ()) {person person = new person (); Person.SoldItems = New List & lt; String & gt; (); // Get the person's person name. Name = dr. Getstring (Dr. Gate Ordinal ("Personality Column")); // Sell item (int i = 1; i & lt; = itemColumnCount; i ++) for / / says that you have columns: ItemSoldColumn1, ItemSoldColumn2, ItemSoldColumn3 example string columnName = "ItemSoldColumn" + i; // Check that the column value is not zero if (! Dr.IsDBNull (dr.GetOrdinal (columnName))) {string soldItem = dr.GetString (dr.GetOrdinal (columnName)); // Add people to the list of items sold to the person. Solditems.ed (sold item); }}}}  

    part two:

      foreach (different person in person) {// label and text the person's name Set up ... newLabel.Text = person.Name; // Add to panel or any layout control // Here you have not sold the loop only through the list of items sold and Texxboxes Fresh (individual items are made in the item. Sold Itims) {// Textbox newTextBox.Text = create item; // Add to Panel or any type of layout control}}  

    PS Think about changing the database structure in individuals - & lt; SoldItems Relationship


    Comments

    Popular posts from this blog

    apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

    c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

    c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -