|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Grid's Column widthI am using .Net Framework 1.1 and ASP.Net & VB.Net.
I want to get width of each column after databind method. Please note I have not assigned width design time, as I am not knowing how many columns will be available. So at the runtime I am binding to datasource and later on I need each column's width to set another control. Also there is a width property available, but it gives always zero (0) in its value. Please help me to find width in pixel. Thanks in Advance. - Kaushik Hi the datagrid has a PreferredColumnWidth property which gives you the
default column width, you can also use the DataGridTableStyle, for example: Dim myCon As New SqlConnection("Data Source=server;Initial Catalog=db;Integrated security=True") Dim myDs As New DataSet Dim myDa As New SqlDataAdapter("select * from ib015", myCon) myCon.Open() myDa.Fill(myDs, "ib015") myCon.Close() Dim tableStyle As DataGridTableStyle tableStyle = New DataGridTableStyle tableStyle.MappingName = "ib015" ' let the dataGrid use the tablestyle and bind it to our table DataGrid1.TableStyles.Clear() DataGrid1.TableStyles.Add(tableStyle) DataGrid1.DataSource = myDs.Tables("ib015") For i As Integer = 0 To myDs.Tables("ib015").Columns.Count - 1 MsgBox(DataGrid1.TableStyles("ib015").GridColumnStyles(i).Width) Next Hope this helps Greetz, Peter -- Show quoteHide quoteProgramming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. (Rich Cook) "Kaushik Gadani" <KaushikGad***@discussions.microsoft.com> schreef in bericht news:7438B715-B4F4-46CB-A32B-69169CB2691C@microsoft.com... > I am using .Net Framework 1.1 and ASP.Net & VB.Net. > > I want to get width of each column after databind method. Please note I have > not assigned width design time, as I am not knowing how many columns will be > available. So at the runtime I am binding to datasource and later on I need > each column's width to set another control. Also there is a width property > available, but it gives always zero (0) in its value. Please help me to find > width in pixel. > > Thanks in Advance. > > - Kaushik
VB Express SQL Express Remote Connection
Trouble with "Process's" please help! .NET equivilant of isnumeric copy HTML information Datagridview Search? How to open a text file only through my application but not others? Text missing from RadioButtons in Groupbox can I use Imports with a VB2005 class namespace? Implementing an interface? Printing in VB.Net |
|||||||||||||||||||||||