Solved

gridview font-size, change dynamically

Posted on 2014-07-31
3
889 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
looking for an ASP.net report designer 4 40
asp.net mvc , views, hidden values ? 2 22
VB.Net SQL Query 2 Tables Different Databases 3 43
WPF Select Items 3 24
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.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

680 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