Solved

gridview font-size, change dynamically

Posted on 2014-07-31
3
798 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
Comment Utility
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
Comment Utility
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 33

Author Closing Comment

by:Mike Eghtebas
Comment Utility
Thank you.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now