Hi I need to make a text grid to display some data.
The requirement is as follows. The grid will always be n by n (a square).
Each cell in the grid needs to display 2 lines of data
1st line of each cell is a 3 char identifier like ABC Font size 8
2nd line of each cell needs to be 4 digit decimal number xx.yy Font size 6
Each cell background needs to be colour coded accoring to the xx.yy value Basically I need an excel style value based conditional formatting
I would like to be able to update each cell with a Control.Update (row,column, values) type function or a Control[row][column] = values type property.
So far I have looked at Gatagridviews but I cannot seem to find a way to implement multi line text entries with different font sizes
Before I decide to write my own control in C# and reinvent the wheel,is there a simpler way to do this. Please note I specifically need each cell to have 2 lines of text and each line of text has a different font size.
My approach will be to create NxNx2 text boxes and the play around with their formatting wrapping this entire mess in a class and then using it in a form with.
But as you can see if I am dealing with a 40X40 data grid this will result in 3200 text boxes. I don't think my approach is the best/correct way to go. Not to mention how difficult it will be to format this as a nice big Square.
PS. I have 0 knowledge of WPF and I have written most of my GUI in c# already
Related
I just started to learn NPOI. I think, that I have some idea how to use it, but I just need two more things to know how to do.
The first one is how to get the minimum size (height and width) of the cell with some text and style, so I will be able to set the correct cell size.
I can't use the auto size feature, because I have structured document and I need some different text in the same column to be on multiple lines.
An example:
I need the column "Name" to have size of "Total amount". Is there a way, how to get the width of the"Total amount" text for selected font?
Thank you.
I have a problem with the alignment of a few names (changed for this question).
with this code I display the names in a richtextbox where it should be in one row with the "Spalte:" after the Names...but it doesn't. Can anybody help me please?
(only the first for-loop is necessary for my question, the next one does another job)
I added a pic what it looks like and how it should be looking. I know I can do it like its in the commented area (doesn't work in every case), but I need to change the code for a few other things so this needs to work....
Here is what I have:
And here is what I want:
Thanks for helping me :D
You have four options:
Change the code for the RichTextBox to use a fixed-width font. Most fonts have variable widths for each character, meaning you can't line things up neatly based on spacing alone.
Use tabs instead of spaces for the layout (and make sure the tab size is large enough to account for variances in your text).
Use a grid control of some type (DataGrid, GridView, etc)
Use a custom control for each row with labels at specific places (and either calculate positions yourself to place them on the form or use something like a FlowLayoutPanel).
I have created a document in an open office with a multi-line form field:
The issue I am having is when the dynamic content exceeds the initial size of the multi-line text box:
Sure I can re-size the Text Box in the original template but the dynamic content may be from 1 to 50 lines and I want the text after the Text Box to be close to the last line of dynamic content.
Can someone suggest a way to solve this?
I have once coded a solution to set the width and height of a textbox programmatically based on the characters supplied. I think this was a school assignment a long time ago.
This can be done with both VBA in a code behind or probably with a macro even. Or with VB.net.
I don't have the code I used way back when, but basically determine the maximum width you are able to provide in character width, the preferred width. Determine the pixel requirement per character for that width. This becomes the textbox width.
Divide your total string character count by your preferred width character count. Round up, calculate the pixel height per character. And use this value times the rounded result for the textbox height. Dirty but it should work.
Any chance you can change to a label and set AutoSize to True? You can fix the width and let the height auto adjust. This should be done before converting to a pdf. In fact all of the sizing should be resovled before pdf conversion.
Another Down voter without a comment, should not be allowed.
I'm developing a VSPackage (extension for Visual Studio 2010), and I have a tool window that is hosting a DataGridView control.
I have a very large data-set (e.g. 2D array of size 16384 x 16384) and I update data via VirtualMode.
I want to add index to the row header cells and column header cells,
so I tried:
Auto resize via grid methods
grid.AutoResizeRowHeadersWidth(
DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders);
Iterating through each row
foreach (DataGridViewRow row in grid.Rows) {
row.HeaderCell.Value = (row.Index + 1).ToString();
}
Subscribing to RowsAdded/OnPaint and updating the value there.
But, all these methods were SUPER SLOW!
They significantly degraded the rendering of the DGV (takes like ~ 5 seconds or more to render the view after each of these methods, or even worse).
What would you suggest to do instead?
I did do initial research into the issue and you've listed all the typical solutions, unfortunately setting 250 million cell values will take some time.
The only thing I didn't see you mention was to fake the header cells (ie first column and row with grey background) and populate them with the source data. Since the DataGridView cell values with be populated with Pixel values one idea is to a append 1 pixel strips to the left and top of each image that you load.
I still think the solution needs a better design. And below are indirect answers to your question.
Make a Picture Dialog with a Zoom-In function. When the user/developer zooms into the pixel level show them the RGB values. Here is an excellend Drawing Tool example written in C# based of MFC CLiDraw and it has an example to show you how to zoom in.
The other idea is a EyeDropper Colour Picker you can get from: http://www.codeproject.com/Articles/36540/Adobe-Eyedropper-Control
So, I have text entered in textbox, which I need to show as preview in label. Problem is, it has specific formatting, so #A is trigger for red color, and text is red colored util some other text color sign is inserted (like we at some point insert #B and text is green from that point, and so on).
That wouldn't be big problem if there weren't two problems:
Obviously this is web application, and although is written in C#, many things that can be done on windows forms, can't be done here.
Bigger problem, that I can't solve is that I also have signs for text background and for text hight (which I would solve in classes).
font color red_____________green___________blue__________
font bacgr. black_________________________________red_____
font hight normal_________________double_________________
I hope you get it, I have three groups of parameters (font color, background color, and text hight) and parameter from one group should change one property, and others should stay.
This is sure complicated, but at least I would need idea how to make that for example #A triggers that color of text in Label becomes red, and that #A is deleted, and when after that is for example #B, at that point text becomes green, and so on.
Have in mind that this is ASP.NET, so many C# features are not available.
The simplest way to accomplish this would be parse the string for your tags and replace them with equivalent HTML/CSS tags (<span class="red">) that implement the formatting you want.