DataGridView Scaling - vb.net

In VB.net 3.5 SP1 I have a Windows Form with three DataGridView controls. One DGV takes up the whole bottom half of the form. The other two share the top half and are side-by-side.
I'd like to have each DataGridView scale appropriately. More specifically I'd like to have column widths and row heights adjust to the size of the form. Then I'd like the cell font to auto-fill based on a change in the cell size.
I've used the Dock property for the controls to scale to the size of the form. How can I get the rows and fonts to utilize the increased form size?
Thanks.

You can use the datagridview.autosizecolumns and the datagridview.autosizerows to autosize the columns and rows. Look at ColumnHeadersDefaultCellStyle, rowHeadersDefaultCellStyleand RowsDefaultCellStyle to change the font
As for changing the fontsize, I don't believe there is any automatic way to handle this. You'll just have to write some code to change the font size based on the size of the datagrid.

Related

Inaccurate Form size

I am trying to create a form with a 500 x 500 form size.
Then I create a panel with a 500 x 500 size.
Logically, the panel size would be the same as the form size.
However, the panel turns out to be significantly larger than the form.
This gave me the conclusion that the form size turns much smaller than the given size which is 500 x 500.
How do I make the form size have the accurate size instead of having it smaller than the given size (e.g. 500 x 500)?
Here is a video that I’ve made to give you guys a clear picture of my problem.
https://youtu.be/RwN2ZpdPMus
The form size refers to the outer edge. The form has a resize border all around it plus a title bar where you cannot place controls. The remaining part inside is the ClientRectangle. You can get its size through
frm.ClientRectangle.Size
' or inside the form itself
ClientRectangle.Size
If you set your panels Dock property to DockStyle.Fill, it will automatically fill up the whole available space. You can do so in the designer in the properties window through a graphical input or in code. The Size property, in this case, is irrelevant.
If you add serveral docked controls, the sequence matters. The fist ones will occupy the outer edges, if docked to some edge.

How to grow all controls within form

I'm having difficulty with resizing controls in two panels...
I have a form with two panels stacked on top of each other. The top panel takes up 38% of the form and the bottom panel takes up 58% of the form and a 4% gap between.I have a tab control in one and group box in the other.
I've been trying to perform fills/docks within the panels that will cause all controls to grow and shrink with the panel's size. In other words I'm trying to keep the same space and size percents for all controls based on the form size. Visual studios keeps crashing when trying different fills/docks and I don't want to calculate size percents and x/y coordinates for each control. Is there a way to set up the fill within the panel or container so that it looks almost the same at most sizes?
In my experience, docking causes more problems than it helps. What I do instead, is undock the controls and then anchor them on all sides. Then I size them within the panel how I want them. Then, if the panel is ever resized, the controls anchored within them will resize accordingly and it will stay within the boundaries like I want it to. Try that.

VB.net: highlight full row without affecting cell backcolor

datagrid
hi guys, Good day! I'm doing a ticketing system with color code in 1st and 2nd column in my datagrid. My question is, how can I fullrowselect my datagrid without affecting the back color of my datagrid in 1st and 2nd column. Please see my image sample
dataGridView.DefaultCellStyle.SelectionBackColor is used to control this color. So set that to your prefered colors. There is more information on this here: https://msdn.microsoft.com/en-us/library/1yef90x0.aspx
You may need to do it dynamically if you're customizing the background colors so you could handle the CellFormatting event and make the changes in there.

vb net: zoom in designer

I was searching google for a way to size the form and the controls with it and came across something that mentioned Control.scale. How do I use the control.scale method to size everything down to the way I want it.
Also, is there a way I can zoom the form out in the designer. I want to create a 1280X800 form, but my screen is 1024X768. I want to be able to zoom out to see the entire form wile still having it's size be 1280X800.
You can use tablelayout panel in order to fit your form in all resolutions.similary a property called anchor, which is also need to be assigned for the controls inside tablelayout panel according to your requirement [top,bottom,left,right] to achieve the same.
By the way you have to use percentage for setting the column's width and row's height in that.
Simply, this way of designing is called as fluid designing.
Table layout panel

In VB.NET, can we draw empty lines instead of blank area in non existent row of datagrid?

EDITED:
I think we can just draw an image that resemble the grid using this article : drawing in a datagridview Currently creating a way to make the image drawn in tile mode. :)
Each time I develop a datacentric application using VB.NET regardless of how much the data displayed in the datagrid, I always want the grid to display full row of empty data, not just blank panel.
Can we achieve this using VB.NET design time property?
And also, we must not trigger the display of vertical scrollbar this way.. :)
Thanks
You might try doing a screen capture of the dgv when it is full of blank lines and use that as your background. However, you'll have a problem with the vertical lines if they resize the columns. In your picture you don't have any vertical lines so if you don't need them then just erase them and your problem is solved.
There's also the option of using the Virtual Mode. When you set that property to true then you can set the number of visible rows, but you are responsible for telling the dgv what each individual cell is supposed to contain: http://msdn.microsoft.com/en-us/library/2b177d6d.aspx
Or you can just add extra blank rows to whatever datasource you are setting your DGV to.
Use the ScrollBars property to turn the vertical scroll bar off.