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. How to improve listbox databind in WIndows Mobile 6

How to improve listbox databind in WIndows Mobile 6

Scheduled Pinned Locked Moved C#
databasehelptutorialquestioncode-review
14 Posts 5 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.
  • E Eder Sa

    My first post and my first mistake. :sigh: I need to load all the data, because when the user types some letters in a filter, the focus moves in the list, searching for the first ocorrence (I use a binary search, but modified and it works fine!) I can move the topic to Mobile Forum?

    []'s

    N Offline
    N Offline
    Not Active
    wrote on last edited by
    #4

    It's too late to move the post now. Populate the list after you have filtered the data.


    I know the language. I've read a book. - _Madmatt

    1 Reply Last reply
    0
    • E Eder Sa

      My first post and my first mistake. :sigh: I need to load all the data, because when the user types some letters in a filter, the focus moves in the list, searching for the first ocorrence (I use a binary search, but modified and it works fine!) I can move the topic to Mobile Forum?

      []'s

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #5

      Eder Sa wrote:

      I need to load all the data, because

      How many entries will the user see when typing? Fetch the top 20 and display that until the user hits enter - and page the rest. Google wouldn't be very efficient if it had to send you all it's search-results and let your browser filter it. Imagine that, with IE4.

      I are Troll :suss:

      E 2 Replies Last reply
      0
      • L Lost User

        Eder Sa wrote:

        I need to load all the data, because

        How many entries will the user see when typing? Fetch the top 20 and display that until the user hits enter - and page the rest. Google wouldn't be very efficient if it had to send you all it's search-results and let your browser filter it. Imagine that, with IE4.

        I are Troll :suss:

        E Offline
        E Offline
        Eder Sa
        wrote on last edited by
        #6

        I implemented your suggestion and like the result. I need to do some more tests and I back later with feedback. Thx!

        []'s

        L 1 Reply Last reply
        0
        • E Eder Sa

          I implemented your suggestion and like the result. I need to do some more tests and I back later with feedback. Thx!

          []'s

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #7

          Cool - you're welcome :)

          1 Reply Last reply
          0
          • L Lost User

            Eder Sa wrote:

            I need to load all the data, because

            How many entries will the user see when typing? Fetch the top 20 and display that until the user hits enter - and page the rest. Google wouldn't be very efficient if it had to send you all it's search-results and let your browser filter it. Imagine that, with IE4.

            I are Troll :suss:

            E Offline
            E Offline
            Eder Sa
            wrote on last edited by
            #8

            Bad news X| I tried use the suggested method and the result of the test in a device (HTC Touch2) is a desaster! The device spend much time running SQLs when I use "like" (about 1~2 seconds). If the user type 100 characters, the total time of the operations is about 100~200 seconds. (not a good result) I did more tests in the device, and the results are worst. Look:

            SQLiteConnection cnn = openCon();
            string SQL = "select cod, desc from produtcs";
            SQLiteDataReader sDR;
            List<MyObj> data = new List<MyObj>();
            cnn.Open();

            // execution time: 1 second (emulator)
            // execution time: 1~2 second (device)
            SQLiteCommand sCommand = new SQLiteCommand(SQL, cnn);
            sDR = sCommand.ExecuteReader();

            // execution time: 5~6 seconds (emulator)
            // execution time: 18~20 seconds (device)
            // alternative test: 1 seconds (emulator)
            // alternative test: 6 seconds (device)
            while (sDR.Read())
            {
            data.Add(new MyObj(Convert.ToInt32(sDR["cod"].ToString()), sDR["desc"].ToString()));
            // Alternative test inserting null objects
            // data.Add(new MyObj());
            }

            // execution time: 6 seconds (emulator)
            // execution time: 18 seconds (device)
            // same times with alternative data
            listBox1.DataSource = data;

            // with GRID VIEW
            // execution time: 0 seconds (emulator)
            // execution time: 0 seconds (device)
            dataGrid1.DataSource = data;

            Now I'll try make it without use a List<> and insert direclty in a listBox. At the moment the best solution. I post my feedback later.

            []'s Eder Sá

            P L 2 Replies Last reply
            0
            • E Eder Sa

              Bad news X| I tried use the suggested method and the result of the test in a device (HTC Touch2) is a desaster! The device spend much time running SQLs when I use "like" (about 1~2 seconds). If the user type 100 characters, the total time of the operations is about 100~200 seconds. (not a good result) I did more tests in the device, and the results are worst. Look:

              SQLiteConnection cnn = openCon();
              string SQL = "select cod, desc from produtcs";
              SQLiteDataReader sDR;
              List<MyObj> data = new List<MyObj>();
              cnn.Open();

              // execution time: 1 second (emulator)
              // execution time: 1~2 second (device)
              SQLiteCommand sCommand = new SQLiteCommand(SQL, cnn);
              sDR = sCommand.ExecuteReader();

              // execution time: 5~6 seconds (emulator)
              // execution time: 18~20 seconds (device)
              // alternative test: 1 seconds (emulator)
              // alternative test: 6 seconds (device)
              while (sDR.Read())
              {
              data.Add(new MyObj(Convert.ToInt32(sDR["cod"].ToString()), sDR["desc"].ToString()));
              // Alternative test inserting null objects
              // data.Add(new MyObj());
              }

              // execution time: 6 seconds (emulator)
              // execution time: 18 seconds (device)
              // same times with alternative data
              listBox1.DataSource = data;

              // with GRID VIEW
              // execution time: 0 seconds (emulator)
              // execution time: 0 seconds (device)
              dataGrid1.DataSource = data;

              Now I'll try make it without use a List<> and insert direclty in a listBox. At the moment the best solution. I post my feedback later.

              []'s Eder Sá

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #9

              The trick is to load the 12K items into an in-memory data structure, and filter on that, rather than using the Like operator against the database.

              I'm not a stalker, I just know things. Oh by the way, you're out of milk.

              Forgive your enemies - it messes with their heads

              My blog | My articles | MoXAML PowerToys | Onyx

              E 1 Reply Last reply
              0
              • P Pete OHanlon

                The trick is to load the 12K items into an in-memory data structure, and filter on that, rather than using the Like operator against the database.

                I'm not a stalker, I just know things. Oh by the way, you're out of milk.

                Forgive your enemies - it messes with their heads

                My blog | My articles | MoXAML PowerToys | Onyx

                E Offline
                E Offline
                Eder Sa
                wrote on last edited by
                #10

                Peter, I already trying do this, but i need improve the load of that 12k items. I already tried serialize and save the data in a file and load the file into the datasource, but the result are not good too. After loaded in memory my data, I use a filter with BinarySearch (modified) and works great. Thx for replys guys :)

                []'s Eder Sá

                P 1 Reply Last reply
                0
                • E Eder Sa

                  Bad news X| I tried use the suggested method and the result of the test in a device (HTC Touch2) is a desaster! The device spend much time running SQLs when I use "like" (about 1~2 seconds). If the user type 100 characters, the total time of the operations is about 100~200 seconds. (not a good result) I did more tests in the device, and the results are worst. Look:

                  SQLiteConnection cnn = openCon();
                  string SQL = "select cod, desc from produtcs";
                  SQLiteDataReader sDR;
                  List<MyObj> data = new List<MyObj>();
                  cnn.Open();

                  // execution time: 1 second (emulator)
                  // execution time: 1~2 second (device)
                  SQLiteCommand sCommand = new SQLiteCommand(SQL, cnn);
                  sDR = sCommand.ExecuteReader();

                  // execution time: 5~6 seconds (emulator)
                  // execution time: 18~20 seconds (device)
                  // alternative test: 1 seconds (emulator)
                  // alternative test: 6 seconds (device)
                  while (sDR.Read())
                  {
                  data.Add(new MyObj(Convert.ToInt32(sDR["cod"].ToString()), sDR["desc"].ToString()));
                  // Alternative test inserting null objects
                  // data.Add(new MyObj());
                  }

                  // execution time: 6 seconds (emulator)
                  // execution time: 18 seconds (device)
                  // same times with alternative data
                  listBox1.DataSource = data;

                  // with GRID VIEW
                  // execution time: 0 seconds (emulator)
                  // execution time: 0 seconds (device)
                  dataGrid1.DataSource = data;

                  Now I'll try make it without use a List<> and insert direclty in a listBox. At the moment the best solution. I post my feedback later.

                  []'s Eder Sá

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #11

                  Is the Sqlite-database located on your HTC? If so, try measuring the load-speed of a textfile to determine whether it can handle your required minimumspeed. I'd be using the GetValues method of the datareader to get an array of objects. Won't be a wowing-difference though. There should also be a SuspendLayout method on your dataGrid control.

                  I are Troll :suss:

                  1 Reply Last reply
                  0
                  • E Eder Sa

                    Peter, I already trying do this, but i need improve the load of that 12k items. I already tried serialize and save the data in a file and load the file into the datasource, but the result are not good too. After loaded in memory my data, I use a filter with BinarySearch (modified) and works great. Thx for replys guys :)

                    []'s Eder Sá

                    P Offline
                    P Offline
                    Pete OHanlon
                    wrote on last edited by
                    #12

                    This is similar to an issue I faced on mobile data terminals (MDTs) a while back. Rather than storing the data in the database, we used a series of indexed files which could quickly be read and parsed at runtime. This meant that the amount of data we held in memory at any one time was minimal, and the processing was extremely rapid.

                    I'm not a stalker, I just know things. Oh by the way, you're out of milk.

                    Forgive your enemies - it messes with their heads

                    My blog | My articles | MoXAML PowerToys | Onyx

                    1 Reply Last reply
                    0
                    • E Eder Sa

                      Hi! I started a development of a application (in Windows Mobile 6) and now i have a little problem: My datasource have 11.000~12.000 registers and when I bind it to my ListBox, this action spend 6 seconds (I think its a lot) and now I want to reduce that time. Anyone now a way to do this? Some code to exemplify my situation:

                      SQLiteConnection cnn = openCon();
                      string SQL = "select cod, desc from produtcs";
                      SQLiteDataReader sDR;
                      List<MyObj> data = new List<MyObj>();
                      cnn.Open();

                      // execution time: 1 second
                      SQLiteCommand sCommand = new SQLiteCommand(SQL, cnn);
                      sDR = sCommand.ExecuteReader();

                      // execution time: 5~6 seconds
                      while (sDR.Read())
                      {
                      data.Add(new MyObj(sDR["cod"].ToString(), sDR["desc"].ToString()));
                      }

                      // execution time: 6 seconds
                      listBox1.DataSource = data;

                      I need populate MyObj after, cuz this I use the variable "data"

                      class MyObj
                      {
                      public MyObj(int p1, string p2){ ... }
                      private int cod;
                      private string desc;
                      private string ...
                      private int ...

                      // set and get methods
                      // ... 
                      

                      }

                      []'s Eder Sá

                      []'s

                      N Offline
                      N Offline
                      Nitheesh George
                      wrote on last edited by
                      #13

                      Hi, Use thread to load and fill the data that will make your application responsive while the data is loading. Using thread in your application is not big deal but you have to take care about thread synchronization in your code. hope this helps. Nitheesh George http://www.simpletools.co.in

                      P 1 Reply Last reply
                      0
                      • N Nitheesh George

                        Hi, Use thread to load and fill the data that will make your application responsive while the data is loading. Using thread in your application is not big deal but you have to take care about thread synchronization in your code. hope this helps. Nitheesh George http://www.simpletools.co.in

                        P Offline
                        P Offline
                        Pete OHanlon
                        wrote on last edited by
                        #14

                        This still doesn't help him lower the 6 seconds or so that he's loading the data.

                        I'm not a stalker, I just know things. Oh by the way, you're out of milk.

                        Forgive your enemies - it messes with their heads

                        My blog | My articles | MoXAML PowerToys | Onyx

                        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