473,487 Members | 2,674 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Datagrid Column widths

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
4 1359
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
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5222
by: TPSreport | last post by:
ASP.NET 2003. Two DataGrids, six columns each, one grid atop the other. I need to have the columns line up, i.e., DataGrid1 Col(1) lined up w/ DataGrid2 Col(1) - each the same width on the...
1
2328
by: TB | last post by:
Hi All: I have this datagrid where space is very tight, and therefore I have to make sure that everything fits within a fixed screen width regardless of whether I am in list mode or in edit...
3
3341
by: Shravan Kumar | last post by:
Hi, I am using my code to set column widths of datagrid columns dynamically, but when I am setting the column widths to zero, the header text of the column whose width is made to zero is...
3
5359
by: bismarkjoe | last post by:
Hello, I am trying to set the widths on the columns of a DataGrid component, and I'm not sure if I'm doing it correctly. My code is below: //load some inital data table = db.GetDataTable(...
9
3927
by: web1110 | last post by:
Hi y'all, I have resized the columns in a DataGrid and I want to set the width of the DataGrid to fit the columns. Just summing the column widths is too short due to the grid and gray row...
1
1222
by: coleenholley | last post by:
I'm getting frustrated with trying to format a datagrid that is entirely populated dynamically using a class module written in VB .Net (No C# used!) We connect to a DB2 database using an RPC that is...
2
6371
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
2
2035
by: TB | last post by:
Hi All: I have this datagrid where space is very tight, and therefore I have to make sure that everything fits within a fixed screen width regardless of whether I am in list mode or in edit...
6
7074
by: cr113 | last post by:
I'm trying to set the column widths for a datagrid. You'd think it would be easy. I looked it up in google and the first thing I found looked promising: datagrid1.columns(0).width = 2000...
4
4183
by: Rich | last post by:
Hello, I have a one datagrid that will be based on different datatables. One datatable may have 7 columns, another 15... With the tables that have more columns, I have been manually dragging...
0
7106
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5442
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4874
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
267
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.