Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27208

How to adjust column width at runtime

$
0
0
I have created a datagrid by codebehind and want to adjust the column width at runtime. I did this:
Code:

mgrid.itemssource=dt.defaultview 
mgrid.Columns(0).Width=200

I got an error that : ... Index is out of range. I then compared data in the grid and data in the datatable to check if there is any data in the grid. I could not find any. I checked like this :
Code:

mgrid.itemssource=dt.defaultview. 
Msgbox( mgrid.Columns.count & “ vs ” & dt.Columns.Count)

The result was : 0 vs 6. However, the code runs fine. I see all 6 columns with data in the grid. What is be wrong here. How can I access data bound in the datagrid and adjust the width size? Please help. Thanks for helping.

Viewing all articles
Browse latest Browse all 27208

Trending Articles



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