Solved

gridview font-size, change dynamically

Posted on 2014-07-31
3
863 Views
Last Modified: 2014-08-03
The intent here is to keep overall width of two side-by-side gridviews fixed at 412px. With 2-digit numbers in the month columns all is fine; however, when there are 3 digits to be reported the gridviews overlap each other (please see the attached image).

Question: Is it possible to decrease font size when the numbers are greater then 99 (for the cell or for the entire row)?

Is it possible to keep gridvies width at 412px fixed so that it will not shrink down when smaller font-size and 1-digit data combination exists?


Thank you.
GridviwGap.png
0
Comment
Question by:Mike Eghtebas
3 Comments
 
LVL 15

Assisted Solution

by:rajeeshmca
rajeeshmca earned 150 total points
ID: 40233646
Hi,

Fix the width of the grids in %.

For your above situation, just try providing fixed width for the columns and Set controls to AllowWrap=True

Regards
Rajeesh
0
 
LVL 10

Accepted Solution

by:
FamousMortimer earned 350 total points
ID: 40233946
Hi,

You can do something like this but it may not be so efficient if the datagridview has many cells.

Dim smallfont As New Font(dgv.Font.Name, 10)
        For Each row As DataGridViewRow In dgv.Rows
            For Each c As DataGridViewCell In row.Cells
                If IsNumeric(c.Value) Then
                    If c.Value > 99 Then
                        c.Style.Font = smallfont
                        Exit For
                    End If
                End If
            Next
        Next

Open in new window

0
 
LVL 34

Author Closing Comment

by:Mike Eghtebas
ID: 40238297
Thank you.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
RLDC Reporting in Visual studio 11 28
JSON  parse help 7 40
parsing JSON help 1 20
Need syntax help building hyperlink 2 20
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question