Dividing a TextBox into columns
-
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?
-
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?
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.
-
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.
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.
-
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?
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
-
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.
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
-
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?
Sounds like you need something like this: WPF: Data Virtualization[^] Further explanations by Bea Stollnitz here[^].
-
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
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.
-
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?
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!]
-
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!]
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