Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to get datagridview column's absolute width after using FillWeight?

$
0
0

I want the width of a DataGridView column after using FillWeight. Here is my code (C#, VS2015). I am trying to set textBox widths the same as dgv column widths. The last line of the code is my concern:

        //Initialise dgv
        //Set column widths for visual appeal
        dgvPRD.Columns["INAME"].FillWeight = 200;
        dgvPRD.Columns["IBATCH"].FillWeight = 150;
        dgvPRD.Columns["DPQTY"].FillWeight = 100;
        dgvPRD.Columns["IPUOMNAME"].FillWeight = 50;
        dgvPRD.Columns["IQTY"].FillWeight = 100;
        dgvPRD.Columns["INOTE"].FillWeight = 300;

        //Initialise textBox locations and sizes
        txtINAME.Left = this.Left + 41; //41 is the RowHeadersWidth of the dgv
        txtINAME.Top = dgvPRD.ColumnHeadersHeight;
        txtINAME.Width = dgvPRD.Columns["INAME"].Width; --> not working (it gives the original column width, before `FillWeight`)

Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>