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. WPF
  4. Dividing a TextBox into columns

Dividing a TextBox into columns

Scheduled Pinned Locked Moved WPF
wpfcsharpalgorithmsregexarchitecture
9 Posts 4 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.
  • D Offline
    D Offline
    Dwayne Barsotta
    wrote on last edited by
    #1

    I am creating an application to learn WPF and MVVM pattern. I have a BindableCollection in my ViewModel with anywhere from 1 to 5000 strings values. I want to put a ListBox or other control in my View that is bound to this Collection. I want the TextBox to be divided into 3 columns and if the data goes further then the three columns can handle, scroll bars are created. I have been searching for hours and can not find a method that is working. Can you anyone direct me in a direction to get this working?

    M L K D 4 Replies Last reply
    0
    • D Dwayne Barsotta

      I am creating an application to learn WPF and MVVM pattern. I have a BindableCollection in my ViewModel with anywhere from 1 to 5000 strings values. I want to put a ListBox or other control in my View that is bound to this Collection. I want the TextBox to be divided into 3 columns and if the data goes further then the three columns can handle, scroll bars are created. I have been searching for hours and can not find a method that is working. Can you anyone direct me in a direction to get this working?

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Member 13610324 wrote:

      I have been searching for hours

      Probably because your requirements are a little weird, or at least the way you a looking at them. For a start no user will want to look at 5000 items in a list - supply a filter before extracting the records from the database. The textbox requirement is not valid, just bind your collection to the listbox, if your collection has more than the 3 columns then create specific columns in xaml (rather than auto generate). A data template will give you very fine control of the content. If you set the column width to "Auto" it will resize to the content (I think). This may end up with a column wider than you view and a scroll bar on the listbox. If you want to manage the width then use word wrap instead of scroll bars. This looks ugly but scroll bars are not available on each cell.

      D 1 Reply Last reply
      0
      • M Mycroft Holmes

        Member 13610324 wrote:

        I have been searching for hours

        Probably because your requirements are a little weird, or at least the way you a looking at them. For a start no user will want to look at 5000 items in a list - supply a filter before extracting the records from the database. The textbox requirement is not valid, just bind your collection to the listbox, if your collection has more than the 3 columns then create specific columns in xaml (rather than auto generate). A data template will give you very fine control of the content. If you set the column width to "Auto" it will resize to the content (I think). This may end up with a column wider than you view and a scroll bar on the listbox. If you want to manage the width then use word wrap instead of scroll bars. This looks ugly but scroll bars are not available on each cell.

        D Offline
        D Offline
        Dwayne Barsotta
        wrote on last edited by
        #3

        The 5k amount of data is not my request, it is that of my boss. Maybe if I explain the purpose of the application. I work for a large truck dealership group. My boss wants a small desktop app that will read a .cvs file of repair order data -> have a box where he can enter the number of repair orders (up to 5k, idk why so much) -> press a button -> a list is populated with the RO number (String) of randomly selected ROs from the CVS file. I am just trying to format some control to make three columns wide with vertical scroll bars if needed, each column will be a continuation of the last. I laid here thinking last night, I could have the code in the viewmodel divide the primary collection into 3 new collections and have those collections bind to a datagrid or multiple column listbox.

        M 1 Reply Last reply
        0
        • D Dwayne Barsotta

          I am creating an application to learn WPF and MVVM pattern. I have a BindableCollection in my ViewModel with anywhere from 1 to 5000 strings values. I want to put a ListBox or other control in my View that is bound to this Collection. I want the TextBox to be divided into 3 columns and if the data goes further then the three columns can handle, scroll bars are created. I have been searching for hours and can not find a method that is working. Can you anyone direct me in a direction to get this working?

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

          I read both your explanations, and still can't visualize your planned UI. In any event, one might use a ScrollViewer to "wrap" the "target control" in order to provide it with scrollbars when it exceeds a certain dimension. Note that the expected results depends on how the target control was constructed; i.e stack panels behave differenently than grids, when it comes to layout. And sometimes, one has to disable one scrollbar, in order for the "other" (V or H) to work properly.

          "(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal

          1 Reply Last reply
          0
          • D Dwayne Barsotta

            The 5k amount of data is not my request, it is that of my boss. Maybe if I explain the purpose of the application. I work for a large truck dealership group. My boss wants a small desktop app that will read a .cvs file of repair order data -> have a box where he can enter the number of repair orders (up to 5k, idk why so much) -> press a button -> a list is populated with the RO number (String) of randomly selected ROs from the CVS file. I am just trying to format some control to make three columns wide with vertical scroll bars if needed, each column will be a continuation of the last. I laid here thinking last night, I could have the code in the viewmodel divide the primary collection into 3 new collections and have those collections bind to a datagrid or multiple column listbox.

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            Dwayne Barsotta wrote:

            divide the primary collection into 3 new collections

            No create the ONE new collection with 3 fields, bind that to the ListBox.

            Dwayne Barsotta wrote:

            The 5k amount of data is not my request, it is that of my boss

            As the developer you need to manage you bosses requirements, point out that loading 5k will be slow and he cannot possibly comprehend the detail of all those records. When he replies that he wants to look at some detail point out that he just defined a filter.

            Never underestimate the power of human stupidity RAH

            D 1 Reply Last reply
            0
            • D Dwayne Barsotta

              I am creating an application to learn WPF and MVVM pattern. I have a BindableCollection in my ViewModel with anywhere from 1 to 5000 strings values. I want to put a ListBox or other control in my View that is bound to this Collection. I want the TextBox to be divided into 3 columns and if the data goes further then the three columns can handle, scroll bars are created. I have been searching for hours and can not find a method that is working. Can you anyone direct me in a direction to get this working?

              K Offline
              K Offline
              Kenneth Haugland
              wrote on last edited by
              #6

              Sounds like you need something like this: WPF: Data Virtualization[^] Further explanations by Bea Stollnitz here[^].

              1 Reply Last reply
              0
              • M Mycroft Holmes

                Dwayne Barsotta wrote:

                divide the primary collection into 3 new collections

                No create the ONE new collection with 3 fields, bind that to the ListBox.

                Dwayne Barsotta wrote:

                The 5k amount of data is not my request, it is that of my boss

                As the developer you need to manage you bosses requirements, point out that loading 5k will be slow and he cannot possibly comprehend the detail of all those records. When he replies that he wants to look at some detail point out that he just defined a filter.

                Never underestimate the power of human stupidity RAH

                D Offline
                D Offline
                Dwayne Barsotta
                wrote on last edited by
                #7

                I took your last comment to heart. After a discussion with him he finally understood, I informed him he needed to break his data down into more manageable chunks.

                1 Reply Last reply
                0
                • D Dwayne Barsotta

                  I am creating an application to learn WPF and MVVM pattern. I have a BindableCollection in my ViewModel with anywhere from 1 to 5000 strings values. I want to put a ListBox or other control in my View that is bound to this Collection. I want the TextBox to be divided into 3 columns and if the data goes further then the three columns can handle, scroll bars are created. I have been searching for hours and can not find a method that is working. Can you anyone direct me in a direction to get this working?

                  D Offline
                  D Offline
                  Dwayne Barsotta
                  wrote on last edited by
                  #8

                  Seems I got downvoted for something here, not sure what. I completed the initial usable version of this application. Per the comments, I received here I redesigned the GUI and operating concepts of the program. Keep in mind this was my first - fully installable C#-WPF-MVVM application ever (second C#). When I got to a (mostly operational) point I had one small bug, I had our company programmer guy look at my program and direct me on my bug (i did have it right, just put the function call in the wrong place). The main idea behind my program was to load a cvs file containing repair order numbers and warranty values, the user can select a min warranty value and the number of records wanted, click a button and the number of random records will be displayed. I was able to include several other (convienence) features as well. I figured - since I got a lot of help here and I really like this site I would share the first version, I have made the GitHub repo public. Hopefully, it will help some others as well as offer me some constructive criticism. BTW - I am being invited to help our code team at work on our in-house projects, this was brought on by him viewing the code for this project, ultimately from the help for y'all. I have always loved coding as a hobby and even took 2 years of online Computer Science, but at 41 years old I resigned myself to the idea I will not become a professional developer, well it looks like that is changing (at least ina small way). This is my long-winded Thank You to all who help! The link to me GitHub Project is below! [Link to my GitHub Project done with your help!]

                  L 1 Reply Last reply
                  0
                  • D Dwayne Barsotta

                    Seems I got downvoted for something here, not sure what. I completed the initial usable version of this application. Per the comments, I received here I redesigned the GUI and operating concepts of the program. Keep in mind this was my first - fully installable C#-WPF-MVVM application ever (second C#). When I got to a (mostly operational) point I had one small bug, I had our company programmer guy look at my program and direct me on my bug (i did have it right, just put the function call in the wrong place). The main idea behind my program was to load a cvs file containing repair order numbers and warranty values, the user can select a min warranty value and the number of records wanted, click a button and the number of random records will be displayed. I was able to include several other (convienence) features as well. I figured - since I got a lot of help here and I really like this site I would share the first version, I have made the GitHub repo public. Hopefully, it will help some others as well as offer me some constructive criticism. BTW - I am being invited to help our code team at work on our in-house projects, this was brought on by him viewing the code for this project, ultimately from the help for y'all. I have always loved coding as a hobby and even took 2 years of online Computer Science, but at 41 years old I resigned myself to the idea I will not become a professional developer, well it looks like that is changing (at least ina small way). This is my long-winded Thank You to all who help! The link to me GitHub Project is below! [Link to my GitHub Project done with your help!]

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

                    If you believe the news, "programming", in terms of quality of life, has exceeded dental and other medical vocations as a preference. Certainly if you can work remotely. I have also found (almost) no "age" discrimination working remote versus "local". (Only do "voice interviews" tho ... tell them "video chats" are for voyeurs).

                    "(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal

                    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