Is it possible to specify a size for the grid view cell when it is in edit mode. The size should be in terms of letters (like we have maximum size for a text box) and not in pixels. My requirement is that user should be able to input not more than 100 characters in the cell when he is editing it.
I want to avoid validating after the user updates as it will get inconsistent with the rest of the site.
Any other work-around is much appreciated.
Any inputs???
Thanks :)
You probably need to use TemplateFields and define EditItemTemplate where you set the maximum length of textbox. Or you could use validation and give error if the input is too big.
Related
The title pretty much describes what I am looking for. I have found answers that are close but not quite what I need. I am hoping someone can explain how to do this or point me in the right direction.
Current setup:
I have multiple user controls. Each contain a grid that has 5 rows and 3 columns. First row definition is set to Height="Auto" and the rest are Height="". First column definition is set to Width="Auto" and the others are set to Width="". I do not want the first row and first column to ever change size but I would like to have the rest of the grid scale.
Question:
I am trying to create a window, which contains a grid, that will dynamically size. The grid contains user controls stated above and each row and column in the window is set to *. I do not want any element in the window to size below what is required for the inner controls (i.e. I do want a button control change sizes but it should never become smaller then Auto width or height). Is there a way to allow for this scalability but do not get any smaller then what the controls requires (ideally within the xaml)?
I don't remember the exact CSS syntax, but I was hoping xaml had something similar to the way CSS sizes content equal to the size of characters on the screen (i.e. Min-Width: 1.5m;)
If you wanted the first row and column to be a static size then don't set them to auto, set the actual size then for the rest of the columns/rows you could use * so they all remain equal
The Source of the Problem
I have a situation where an old WinForms grid was placed in a PageView, then generates another page and sets it active if you click one of the rows. The original idea was that the second PageViewPage's grid would contain "detail information" and that the original grid would bear a summary, but over the years more and more data from the detail page has been added to the original grid. This turned a 6-column GridView that needed to be stretched to fit the screen into a 20-column GridView that causes a lot of scrolling to happen, especially in our manufacturing plants where some of the oldest machines still have 1024 x 768 CRT's.
The Problem
I'm developing on this screen, now using Telerik controls. My task is to find a way to display all of the data from both pages in the one grid, but with little-to-no horizontal scrolling required. After appending the few fields which were not already duplicated and combining related data (i.e. Account Number and Account Name being one hyphenated column with word wrap instead of two), I've got 19 columns. 1/3rd of the grid is still offscreen.
SO far I have:
Combined like data (as above)
Reduced font sizes slightly
Changed the BestFitColumnsMode to DisplayedCells
Reduced all columns which had a fixed number of characters to display to the right size to display only those characters
Abbreviated column names that are larger than their potential data and replaced with a symbolic icon on CheckBoxColumns
Replace all written-out "true" - "false" TextBoxColumns with CheckBoxColumns
Now I'm stuck. I considered dropping the column headers and instead making a bunch of RadGridView pairs for each line, effectively "wrapping" the grid, but that would rob me of the sorting and grouping features we actually need which are provided by Telerik out of the box. Is there a "best practice" for situations like this, or perhaps a feature of GridView or RadGridView I'm missing?
One option has already been ruled out; I can't replace this with a list of UserControl that contains labels (i.e. "ID: xx" instead of an ID column with xx in a cell) or similar. Column headers are required by the project.
I would like to simply enable autosizing on my datagridview (or similar behavior). I want some columns to grow and fill all available space. However, I also have some columns that I want 100% fixed and to not grow at all, and I can't get this particular behavior.
Unfortunately, no matter what the fill rate is, I can't figure out how to lock the columns I don't want to change. So far, I have tried:
Setting FillWeight to be extremely small on the columns I want locked. Unfortunately, this just causes the column to become sized too small off the bat, regardless of its initial width setting.
Setting Resizable = DataGridViewTriState.False only prevents the user from changing the size of that column. It still resizes automatically when I change the window size.
Does a solution exist? If I can't find one, I'll need to write up my own implementation, triggered using DataGridView.Resize I take it.
I see, MinimumWidth needs to be leveraged as part of the solution. FillWeight = float.Epsilon, MinimumWidth = 50 seems to do the trick.
We have a case where we need to display Character Ellipsis(i.e. show text as trimmed) when we have multiline text.
The textblock shows trailing ellipsis when the content is anyway bigger than the width of the multiline TextBlock (i.e. TextWrapping is set to Wrap).
But we have a case wherein, we need to show only one line with ellipsis whether the text width of the first line is greater than the width of textblock or not.
For example, consider the following sample text
String str = "1\n2\n3456\n45889";
textBlock.Text = str;
The TextBlock should display as shown below:
1...
and the ToolTip will show the entire text. I tried doing some research on the possibilities but could not find much help and was wondering if anyone in the community has encountered such a situation or perhaps could suggest me?
Since, we shouldn't change the underlying data object (real time scenario) but only change what is rendered to the user, I am guessing a Converter should do the trick but I am still stuck on how to proceed. Or do you guys have any other alternatives?
Create a custom control based off of the textblock which handles the business logic needed for the ellipse.
The binding of the actual text to a specific property can ensure that the text is not changed. While in a separate property you have the visual text with the ellipse which gets updated when the original text changes (the dependency property change event) and the visual text subsequently displayed on the screen. Also have the tooltip bound to the original text which helps in that scenario of showing the actual text and not the ellipsed text.
By creating an easy custom control you have the ability to handle the business logic all in one location and it can be used in other screens and projects.
I'm building a Windows Store App that uses a GridView to show a list of items (basic, out of the box template). I would like to know if I can get the total width that all the items take up.
Right now I'm taking the number of item columns and multiplying it by the total width of one of the items. This is working, but it requires that my code behind knows way too much about my view. I'd like to find the one property that has the width and just bind to it.
Thanks for any help!
Here is the code that I have to get the column width of the GridView
(itemGridView.ItemContainerGenerator.ContainerFromIndex(0) as GridViewItem).ActualWidth
I don't have a good way to get the number of Columns, so that would also be helpful
The ActualWidth property of the GridView should contain the information you are looking for.
If not, you could try to call Measure on the gridview to let it perform the required layout calculus and output its desired Size.