Groups | Blog | Home
all groups > vb.net controls > july 2005 >

vb.net controls : DataGrid columnwidth


max
7/11/2005 6:31:07 AM
I am trying to set the witdth of the datagrid's 1st column so that the
second column butts up next to the edge. But this doesn't work. Any
ideas??

Dim colJD As New DataColumn
Dim colAmt As New DataColumn
'Define Column Job Description
colJD.DataType = System.Type.GetType("System.String")
colJD.ColumnName = "JobDescription"
colJD.Caption = "Job Description"
colJD.ReadOnly = False
tblJD.Columns.Add(colJD)
'Define Column Amount
colAmt.DataType = System.Type.GetType("System.Decimal")
colAmt.ColumnName = "Amount"
colAmt.Caption = "Amount"
colAmt.ReadOnly = False
tblJD.Columns.Add(colAmt)
dgJobDesc.DataSource = tblJD

Dim ts As New DataGridTableStyle
ts.MappingName = "JobDescription"
Dim textcol As New DataGridTextBoxColumn
textcol.MappingName = "JobDescription"
textcol.HeaderText = "Job Description"
textcol.Width = 300
textcol.ReadOnly = False
ts.GridColumnStyles.Add(textcol)

DirectCast(dgJobDesc.DataSource, _
DataTable).DefaultView.AllowNew = False
dgJobDesc.TableStyles.Add(ts)


Thank you,
Ken Tucker [MVP]
7/11/2005 7:29:27 PM
Hi,

http://64.78.52.104/FAQ/WinForms/FAQ_c44c.asp#q871q

Ken
--------------------
[quoted text, click to view]
second column butts up next to the edge. But this doesn't work. Any
ideas??

Dim colJD As New DataColumn
Dim colAmt As New DataColumn
'Define Column Job Description
colJD.DataType = System.Type.GetType("System.String")
colJD.ColumnName = "JobDescription"
colJD.Caption = "Job Description"
colJD.ReadOnly = False
tblJD.Columns.Add(colJD)
'Define Column Amount
colAmt.DataType = System.Type.GetType("System.Decimal")
colAmt.ColumnName = "Amount"
colAmt.Caption = "Amount"
colAmt.ReadOnly = False
tblJD.Columns.Add(colAmt)
dgJobDesc.DataSource = tblJD

Dim ts As New DataGridTableStyle
ts.MappingName = "JobDescription"
Dim textcol As New DataGridTextBoxColumn
textcol.MappingName = "JobDescription"
textcol.HeaderText = "Job Description"
textcol.Width = 300
textcol.ReadOnly = False
ts.GridColumnStyles.Add(textcol)

DirectCast(dgJobDesc.DataSource, _
DataTable).DefaultView.AllowNew = False
dgJobDesc.TableStyles.Add(ts)


Thank you,
--max

max
7/14/2005 12:21:32 PM
Hi Ken,

Thanks for the lead, it worked.

How then do I control the datagrid so that different rows have
different heights? I am creating a small invoicing app and the user
wants to enter long descriptions which might wrap to several visual
rows. a) How do I determine how many rows are needed and then b) how
do I change that row so that all the data can be seen?

Thanks,
--max

On Mon, 11 Jul 2005 19:29:27 -0400, "Ken Tucker [MVP]"
[quoted text, click to view]
Ken Tucker [MVP]
7/14/2005 6:11:25 PM
Hi,

http://www.windowsformsdatagridhelp.com/default.aspx?ID=59135549-e5dd-4501-9526-343ac05a7617

Ken
-----------------------
[quoted text, click to view]

Thanks for the lead, it worked.

How then do I control the datagrid so that different rows have
different heights? I am creating a small invoicing app and the user
wants to enter long descriptions which might wrap to several visual
rows. a) How do I determine how many rows are needed and then b) how
do I change that row so that all the data can be seen?

Thanks,
--max

On Mon, 11 Jul 2005 19:29:27 -0400, "Ken Tucker [MVP]"
[quoted text, click to view]

AddThis Social Bookmark Button