I will have to create a Control that supports multiline-copy of text. It looks like this:
Label1: ContentLine1 Label2: ContentLine2 (right aligned)
Blah: ContentLine2 Hyperlink
Label3: ContentLine 3 (needs to collapse if no extended info available)
Problems: Mixed styles (bold labels, regular content and hyperlink)
I tried using RTF + FlowDoc with tables. I ultimately gave up after many problems (like no autosizing columns in flowdoc) at the hyperlink I could not get to work. I works in normal mode though. Also the visibility thing is complicated in flowdoc. I had to add and remove the last row when I only wanted to hide it.
I am currently thinking about building a customcontrol giving me the selection like in a WORD-Table. You can start in the left upper cell and just roll down to the right side or just select a part.
Things I also tried so far: A stylized DataGrid: worked good for Layout, but copying did not work as expexted.
Single TextBoxes stlyed as labels... doesn't work for more than one at a time.
Does anybody know I can mimic the textbox selection behaviour over multiple controls, like using mousemove / events to do the magic?
Thanks in advance! :)
Related
I have a C# program that uses an Infragistics UltraWinGrid to display comments. A comment can be multiple lines. That is, it can contain carriage return/line feeds (CRLFs). (See the upper portion of the attached screenshot.) But when the user selects the text of the comment by clicking on the cell, it loses the CRLFs. (See lower portion.) This is a problem, because comments can be very long and the user may want to copy and paste a comment somewhere else without losing the formatting.
From what I understand, this problem results because the grid uses a Windows textbox as an editor when the user clicks on a cell. Is there some way that I can either make the textbox keep the CLRFs or replace the textbox with an editor that does? Thanks.
Turns out there are a few stars that need to align for this.
Of course CellMultiLine needs to be set for the column like wnvko pointed out.
But also, you must make sure your Column Style is NOT FormattedText or FormattedTextEdit. (If that's required for editing i think you are out of luck). Just use Default style.
And finally make sure you CRLFs are actually truly CRLFs. My best suggestion is to use Environment.NewLine. If you are pulling the data from the DB, make sure you use CHAR(13) + CHAR(10) in that specific order. See Differences Between vbLf, vbCrLf & vbCr Constants
Hope this helps 4 years later. :-) But wanted to share for others since i found no solution elsewhere.
My suggestion is to use Templates. Have a look at the official Infragistics UltraWebGrid help book that is explaining in depth how to configure features like Row and Column Templates.
Go to page 74 for more information regarding the templating.
You should set CellMultiLine of the column to True. Here is how it is working when I set it in my grid
I never found a real answer to this question, but I was able to do a workaround by capturing the click event and having it open a small dialog box containing the cell text. I had the dialog box open at the point the user clicked, so that it appeared over the cell. After a few minor adjustments to take care of border conditions, it worked surprisingly well, so I'm calling this one solved. Thanks, everyone, for your suggestions.
Sorry but I am a newbie to WPF, I would really appreciate if you could help me-
Tag 1 in pic- Which control can I use to create a menu similar to that in the picture ? The closest I came was using a gridview within a listview but that ends up using a header for the gridview. Normal listview just highlights the entire strip and doesn't look good at all.
Tag 2 in pic // (No longer relevant, sorry)
Edit:
Looking for something simple like when using gridview with listview (as in pic below) there is automatically that standard window gradient & bevel effect etc. (As an idea, implementing it with buttons seems to cumbersome, first strip button border, then create all these effects.) So essentially anything already inbuilt in WPF.
Thanks for any help :-D !!!
ListBox or ListView are good controls to use. If it's just the 'pretty' factor you don't like, you can provide Templates to change the appearance. But functionally, ListBox and ListView provide the function of that menu.
When working with WPF, that should be your primary motivation when choose controls. What FUNCTIONS the way you want. You can always make it LOOK different with Templates, but getting the right FUNCTION is the primary goal for the control.
I am working on a project in C# on the .net micro framework, using the GHI Glide graphical library. I need to navigate a DataGrid through the use of directional keys and a numeric keypad (and NO touchscreen). There is an enter button which I am using to activate what I call "Edit DataGrid Mode", where I call the following on the DataGrid myGrid (which selects row 10, for example, and colors it yellow): myGrid.SelectedIndex = 10;
Problem is, I would like to be able to enter into a "Edit Cell Mode" when I click the enter button again, but in the DataGrid class, there doesn't seem to be any way to show a cell is selected. I thought about using a popup window that would get the data from the cell and then proceed from there, but I would rather avoid popups in favor of a more streamlined approach.
Am I missing something about how I could trigger touch events to make a cell select? Or should I just go the hardcore route and use something similar to window.Graphics.DrawTextInRect(...); to make a text rectangle appear over the cell I am editing?
Change the selection unit property of the Datagrid. Selection Mode would be the alternative to your problem if selection unit is already on cell.
Thanks for your help, but I found that the GHI Glide graphical library for .net micro framework does not have this capability, and other ways of inputting data must be used (sorry for the confusion, there wasn't a tag for Glide). I ended up using a TextBox component to serve as a background and adding other components on top of it, setting the text of those components as I retrieved data from the table.
I am using a Library that has a class of type GanttChartDataGrid. For this question I am just concerned with the Datagrid. Currently, I used this code to acheive single click to edit in the grid. Single Click to Edit Code.
This works great, but the issue is, since my textboxes are in edit mode, they are exposed and you can see them. Making the datagrid look ugly here is a picture:
The cells under "Task" are all exposing their textboxes. In the next picture, I would like the cells to behave like how duration is. It shows it like a label within the grid and if it is not selected, once it becomes selected it displays the textbox.
I would like it to display the underlying textbox only when that row is selected.
Thanks!
I figured out my question.
I was databinding to Textboxes, I changed those to textblocks and now it works great.
I am currently working on a project that displays user data in a grid, each user has a total and when clicked expands out to show the sub items that make up that total and they can be expanded again to show even more details.
I currently achieve this by using a DataGridView with its data bound to a DataTable, I hide the sub items for each user in the "RowsAdded" event and then just show/hide them as the main user lines/sub lines are clicked.
The Main problem with this is the scroll bar jumps a lot when data is changed and I require it to only move when the user wants it to.
I also have a requirement that no line must ever be covered and the parent lines should show totals of the values in the child (I can do this part manually the more important part is that its not a grouping like with a outlook style list).
My question is: Is there a better way to have expanding entries in a table format? And if hiding and un-hiding is the only way then any idea how to fix the scrolling problem?
I have tried hiding and showing lines as I have already said and I have also tried hiding and showing another Control (in this case another DataGridView) the problem with this approach is that it covers the other rows as I have yet to find a suable way to pad out a space for the control to be in.
You can use the following code to eliminate the scrolling animation.
dataGridView1.ScrollBars = ScrollBars.None;
// Do your show/hide on your datagridview rows
dataGridView1.ScrollBars = ScrollBars.Both;
In the End there was no satisfactory way to do this with winforms so I was forced to swap to WPF and I had everything running in about 2 hours.
My end solution was to use a DataGrid with rowdetails that contain a DataGrid.