By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,441 Members | 996 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,441 IT Pros & Developers. It's quick & easy.

Datagrid Column widths

P: n/a
I'm filling the datagrid with no problem but I do not see a columnwidth
property anywhere. How do you set the columnwidth property of the datagrid
columns in code or manually?
Thank you.

Paul
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
One of the properties is called TableStyles. From there you can define all
the properties of each column.

--
Bob Hollness

-------------------------------------
I'll have a B please Bob

"Paul Ilacqua" <pi******@twcny.rr.com> wrote in message
news:uy**************@TK2MSFTNGP15.phx.gbl...
I'm filling the datagrid with no problem but I do not see a columnwidth
property anywhere. How do you set the columnwidth property of the datagrid
columns in code or manually?
Thank you.

Paul

Nov 21 '05 #2

P: n/a
"Paul Ilacqua" <pi******@twcny.rr.com> schrieb:
I'm filling the datagrid with no problem but I do not see a columnwidth
property anywhere. How do you set the columnwidth property of the datagrid
columns in code or manually?


<URL:http://msdn.microsoft.com/library/en-us/dv_vstechart/html/vbtchformattingwindowsformsdatagridvisualbasicprim er.asp>
-> "Setting Column Width"

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3

P: n/a
This grid is populated with a data adapter... IE

With grd_inventory

..SetDataBinding(ds_Work, "Line Summary")

..BackColor = System.Drawing.Color.Khaki

..CaptionText = "Line Summary"

End With

Can I set the column width's in here somewhere? They don't seem to work
manually.


"Bob Hollness" <bo*@blockbuster.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
One of the properties is called TableStyles. From there you can define
all the properties of each column.

--
Bob Hollness

-------------------------------------
I'll have a B please Bob

"Paul Ilacqua" <pi******@twcny.rr.com> wrote in message
news:uy**************@TK2MSFTNGP15.phx.gbl...
I'm filling the datagrid with no problem but I do not see a columnwidth
property anywhere. How do you set the columnwidth property of the
datagrid columns in code or manually?
Thank you.

Paul


Nov 21 '05 #4

P: n/a
hi,

i have been strugling with this problem to i can give you somme code of my
project i hop it helps

Private Sub AddCustomDataTableStyle3()

Dim ts1 As New DataGridTableStyle()

ts1.MappingName = "Digitaal"

ts1.ForeColor() = Color.Black

ts1.AlternatingBackColor = System.Drawing.Color.LightGray

ts1.BackColor = System.Drawing.Color.DarkGray

ts1.ForeColor = System.Drawing.Color.Black

ts1.GridLineColor = System.Drawing.Color.Black

ts1.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None

ts1.HeaderBackColor = System.Drawing.Color.Silver

ts1.HeaderForeColor = System.Drawing.Color.Black

ts1.LinkColor = System.Drawing.Color.Navy

ts1.SelectionBackColor = System.Drawing.Color.Navy

ts1.SelectionForeColor = System.Drawing.Color.White

//This part sets up the wole datagridstyle

Dim boolCol As New DataGridBoolColumn()

boolCol.MappingName = "State"

boolCol.HeaderText = ""

boolCol.Width = 15

ts1.GridColumnStyles.Add(boolCol)

Dim NameCol As New DataGridTextBoxColumn()

NameCol.MappingName = "Channel"

NameCol.HeaderText = "Chan"

NameCol.Width = 40

ts1.GridColumnStyles.Add(NameCol)

DataGrid3.TableStyles.Add(ts1)

TablesAlreadyAdded = True

Dim ChannelCol As New DataGridTextBoxColumn()

ChannelCol.MappingName = "Name"

ChannelCol.HeaderText = "Name"

ChannelCol.Width = 100

ts1.GridColumnStyles.Add(ChannelCol)

DataGrid3.TableStyles.Add(ts1)

TablesAlreadyAdded = True

//this part ads the collumn 1 chechbox collumn, and 2 textbox collumns

Private Sub MakeDataSe3t()

myDataSet3 = New DataSet("myDataSet")

Dim cont As New DataTable("Digitaal")

Dim Name As New DataColumn("Name", GetType(String))

Dim Channel As New DataColumn("Channel")

Dim Status As New DataColumn("State", GetType(Boolean))

cont.Columns.Add(Status)

cont.Columns.Add(Name)

cont.Columns.Add(Channel)

myDataSet3.Tables.Add(cont)

Dim newRow1 As DataRow

For inti = 0 To 15

newRow1 = cont.NewRow()

newRow1("Name") = dchanName(inti + 1)

cont.Rows.Add(newRow1)

cont.Rows(inti)("Channel") = inti + 1

cont.Rows(inti)("State") = (False)

Next inti

End Sub

i don't fill up the grid by coupling it with a database, but fil it like the
above way
what's important, is that you use the correct mappingname to link yourre
dataset to the datatable.

I hope it helped

kind regards Maarten
"Paul Ilacqua" <pi******@twcny.rr.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
This grid is populated with a data adapter... IE

With grd_inventory

.SetDataBinding(ds_Work, "Line Summary")

.BackColor = System.Drawing.Color.Khaki

.CaptionText = "Line Summary"

End With

Can I set the column width's in here somewhere? They don't seem to work
manually.


"Bob Hollness" <bo*@blockbuster.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
One of the properties is called TableStyles. From there you can define
all the properties of each column.

--
Bob Hollness

-------------------------------------
I'll have a B please Bob

"Paul Ilacqua" <pi******@twcny.rr.com> wrote in message
news:uy**************@TK2MSFTNGP15.phx.gbl...
I'm filling the datagrid with no problem but I do not see a columnwidth
property anywhere. How do you set the columnwidth property of the
datagrid columns in code or manually?
Thank you.

Paul



Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.