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
Related
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
I've write a program that construct a 2D matrix from txt file, and build a winforms panel with X*Y labels wich contains a char, coordinates, color and border (if select it).
it is my DrawGrid routine:
Container.SuspendLayout();
for (int y = 0; y < template.Matrix.GetLength(1); y++)
{
for (int x = 0; x < template.Matrix.GetLength(0); x++)
{
var curLabel = new LabelTemplate(template.Matrix[x, y].Content, x, y, spacing);
_templateCells.Add(curLabel);
Container.Controls.Add(curLabel);
}
}
Container.ResumeLayout();
whit it I view a txt file in my form, and select a row or columns or area with mouse, manipulate and save new text files from it getting content and coordinates from my LabelTemplate object (extends Label).
I've always test my program with a little txt files in input.
Today i've tested with a big txt file (9000 rows * 50 columns) and i've reached a maximun handles of a windows form application.
(an Win32 Exception is launched during Container.Controls.Add(curLabel)).
Googling i've found that the limit of controls in winforms application is 10000 handles.
Also view a lot of label on my form (if 10000 is a modificable value), performance are very bad (if i scroll container panel, i wait a lot of time to view results)!
There is a way or control that help me?
I think also to GDI+, but what is the right way for you? Any suggestions?
Thanks in advance
I think you should use DataGridView control.
If your amount of data is too big, you can limit the number of items and add some control to select the start of the region that you are viewing (like a NumericUpDdown or a TrackBar). Every time you change the start index, you reload your data to the DataGridView.
Sample of how to fill a DataGridView from an array: "How do I show the contents of this array using DataGridView?".
Another solution would be to use WPF, which has built-in UI Virtualization, therefore supports much bigger datasets without having any performance impact.
It is not practical to use labels for cells of a grid-like control. As agent5566 suggested, you can use DataGridView control for a fast approach or if you want full control and better performance, you can use a single UserControl and paint everything on it, handle keystrokes, simulate focus on cells (if needed) and so on.
My project needs to display a list of contacts in a grid. Normal data - First Name, Last, City, State, Zip, Email, Phone, Company Name.
1 - We need to support wide variation in screen widths 800px -> 2,000px.
2 - We want to display as much information as possible, with as little white space as possible.
3 - As the grid gets wider, we want some fields to expand (Organization Name), others to stay at a maximum Width (State - 2 char).
None of the standard column resize modes seem to work since there is no Max Width column. The State column ends up with a ton of space, and the organziation is still being chopped off.
Has anyone resolved this problem?
I had similar problems with our Gridview and I have raised a ticket with Devexpress team for the same reasonsDevexpress ticket. It seems SetWidth() client side JS method does not work properly when you have fixed width columns.
In your case, I would suggest using percentage size for your columns which needs to be dynamically expanded and static size for the other ones.Also set the text wrap true for cells that you want texts tightly wrapped inside.
settings.Columns.Add(column =>
{
var commmonHeaderStyle = column.HeaderStyle as GridViewHeaderStyle;
commmonHeaderStyle.Font.Bold = true;
column.CellStyle.Wrap = DefaultBoolean.True;
column.FieldName = "Test";
column.Width = System.Web.UI.WebControls.Unit.Percentage(30);
});
You might also want to take a look at this example : Full Screen mode (100% browser Width and Height)
I've got two chart types sharing one chart area. One of the charts is a smooth area chart (three of this type are generated but only one is shown in the designer), the other is a column chart.
The purpose of the column chart is to indicate where some limits are located on the smooth area chart. The charts are created well except that the smooth area chart has gaps where the limit lines show up.
How do I get rid of the gaps that are occurring? The following images are print screens of my issue.
Thanks
Turns out that the column chart data is included in the C# list that I'm using as a data source for these charts. So, when making the smooth area graphs it is using those red lines values as a data point, causing a gap because they're y value is set to 0. There is no gap, just a 0 value.
The column chart y values are actually a different parameter with a random name but using the same dataset, since the smooth area chart doesn't have that value set, they are effectively 0, so you don't see them show up as columns.
The real problem is that I basically need to show data conditionally, or get two datasets in one chart.
I'm designing a Point and Figure Charting program, and my first version used the DataGridView control, which I found to be too big and bloated for my needs. All I need is a simple control that displays a square grid which will be filled with X's and O's.
The data is parsed from yahoo finance as Open, High, Low, Close data, sorted by a set of rules and converted to an Int Array, which will correspond with the index of the rows, so the simpler the control is, and the less bloat is has the more efficient it will be when chewing through large amounts of data.
I also need to be able to easily adjust the size of the squares in the grid, to zoom in and out of the data.
I am unfamiliar with creating custom controls (But willing to learn), and I'm not having a lot of luck with the search terms I'm using, so any help pointing in the right direction would be appreciated.
I've implemented a couple of custom controls like this before usually colour/graphics related stuff and they usually end up being more work than you imagine.
In the last project where I needed to do custom display stuff (a massive matrix of TCPConnection status between many different machines) I just used Xceed's gridControl and dynamically added the columns to the control. I kept an internal dictionary of the index of the column I added so that subsequent rows could benefit from direct reference to the column.
There are many different grid controls that you could probably utilise. Or if you want to get down and dirty with a Custom Control using the *Pain*t stuff you can do that too.
property for Columns, Rows .. Calculate the Space available then draw your Horiz/Verticals then draw you other values in the correct spaces, but eek prepare to invest quite a bit of time getting it "just right"