473,407 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Datagrid column width won't change

Ben
Could someone please tell me why couldn't I adjust my column/row properties
of my dataGrid? I binded my table, created a new DataGridTableStyle and
mapped it to my datagrid. However, my columns width wouldn't changed at all.
I am sure this is very easy thing to figure out but I just couldn't see it.
Could you please take a look at my codes. What I am missing? Btw, I got
these codes from MSDN website:

thanks.

.....
Private myDataGrid As DataGrid
Private myDataSet As DataSet
Private TablesAlreadyAdded As Boolean
Private ts1 As New DataGridTableStyle
....

from my default constructor, I rand SetUp()
......
Private Sub SetUp()
'create a dataset with two tables and one relation.
MakeDataSet()
'bind the datagrid to the dataset. the datamember
'specifies that the customers table should be displayed.
myDataGrid.SetDataBinding(myDataSet, "customers")

Dim ts1 As New DataGridTableStyle
ts1.MappingName = "customers"
Dim myDataCol As New DataGridBoolColumn
myDataCol.HeaderText = "My New Column"
myDataCol.MappingName = "current"
myDataCol.Width = 4000000
ts1.GridColumnStyles.Add(myDataCol)
myDataGrid.TableStyles.Add(ts1)

End Sub
.....................along that path, it should execute this dataset then
bind to myDataGrid
Private Sub MakeDataSet()
myDataSet = New DataSet("myDataSet")

Dim tCust As New DataTable("Customers")
Dim cRecordName As New DataColumn("Record Name", GetType(Integer))
Dim cUnitOfMeasurement As New DataColumn("Unit Of Measurement")
Dim cSimulationCaseNo As New DataColumn("Simulation Case Number")
tCust.Columns.Add(cRecordName)
tCust.Columns.Add(cUnitOfMeasurement)
tCust.Columns.Add(cSimulationCaseNo)

myDataSet .Tables.Add(tCust)

Dim newRow1 As DataRow

Dim i As Integer
For i = 1 To 3
newRow1 = tCust.NewRow()
newRow1("Record Name") = i
tCust.Rows.Add(newRow1)
Next i
tCust.Rows(0)("Unit Of Measurement") = "Customer1"
tCust.Rows(1)("Unit Of Measurement") = "Customer2"
tCust.Rows(2)("Unit Of Measurement") = "Customer3"

tCust.Rows(0)("Simulation Case Number") = "asdf"
tCust.Rows(1)("Simulation Case Number") = "asdf"
tCust.Rows(2)("Simulation Case Number") = "asdfdas"
End Sub
Nov 21 '05 #1
2 1830
Hi,

The mappingname for the tablestyle is case sensitive. Try
using Customers instead of customers. Not sure if the datagrid supports
column widths of 4000000

Ken
--------------------
"Ben" <Be*@discussions.microsoft.com> wrote in message
news:2A**********************************@microsof t.com...
Could someone please tell me why couldn't I adjust my column/row properties
of my dataGrid? I binded my table, created a new DataGridTableStyle and
mapped it to my datagrid. However, my columns width wouldn't changed at
all.
I am sure this is very easy thing to figure out but I just couldn't see it.
Could you please take a look at my codes. What I am missing? Btw, I got
these codes from MSDN website:

thanks.

.....
Private myDataGrid As DataGrid
Private myDataSet As DataSet
Private TablesAlreadyAdded As Boolean
Private ts1 As New DataGridTableStyle
....

from my default constructor, I rand SetUp()
......
Private Sub SetUp()
'create a dataset with two tables and one relation.
MakeDataSet()
'bind the datagrid to the dataset. the datamember
'specifies that the customers table should be displayed.
myDataGrid.SetDataBinding(myDataSet, "customers")

Dim ts1 As New DataGridTableStyle
ts1.MappingName = "customers"
Dim myDataCol As New DataGridBoolColumn
myDataCol.HeaderText = "My New Column"
myDataCol.MappingName = "current"
myDataCol.Width = 4000000
ts1.GridColumnStyles.Add(myDataCol)
myDataGrid.TableStyles.Add(ts1)

End Sub
.....................along that path, it should execute this dataset then
bind to myDataGrid
Private Sub MakeDataSet()
myDataSet = New DataSet("myDataSet")

Dim tCust As New DataTable("Customers")
Dim cRecordName As New DataColumn("Record Name", GetType(Integer))
Dim cUnitOfMeasurement As New DataColumn("Unit Of Measurement")
Dim cSimulationCaseNo As New DataColumn("Simulation Case Number")
tCust.Columns.Add(cRecordName)
tCust.Columns.Add(cUnitOfMeasurement)
tCust.Columns.Add(cSimulationCaseNo)

myDataSet .Tables.Add(tCust)

Dim newRow1 As DataRow

Dim i As Integer
For i = 1 To 3
newRow1 = tCust.NewRow()
newRow1("Record Name") = i
tCust.Rows.Add(newRow1)
Next i
tCust.Rows(0)("Unit Of Measurement") = "Customer1"
tCust.Rows(1)("Unit Of Measurement") = "Customer2"
tCust.Rows(2)("Unit Of Measurement") = "Customer3"

tCust.Rows(0)("Simulation Case Number") = "asdf"
tCust.Rows(1)("Simulation Case Number") = "asdf"
tCust.Rows(2)("Simulation Case Number") = "asdfdas"
End Sub
Nov 21 '05 #2
Ben,

Mostly these errors come if you don't use the same cases as you do in your
code
This part is with windowsforms programming case sensitive (rarely it is not
with a webform datagrid).

I hope this helps,

Cor
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Eva | last post by:
How do i indivually change the width of a datagrid coloumn? I am currently using the PrefferedColoumnWidth property, but due to space restrictions i do not want all the columns at the same...
5
by: Prateek | last post by:
Hi, How can I change the width of a column in datagrid control? TIA Prateek
1
by: Tim Wallace | last post by:
I have a .NET 1.1, C# desktop application. In this app, there is a window wherein I use the DataGrid control to display info for the user to edit. I then grab that data (which initially comes...
1
by: | last post by:
How do I change the datagrid column width dynamically when the grid's being loaded? VM
3
by: frank | last post by:
How do I set the column width of a column in a DataGrid programatically (in ASP.NET web pages)? I understand I may have to use DataGridTableStyle, but I can't get this to work with web pages. ...
24
by: Mike L | last post by:
This is for a Win form, in C# 2005. I want to load a datagrid, make some columns width 0, and then clean out the record I added. I get the error message, ""Index was out of range. Must be...
1
by: salih ataoz | last post by:
i have a form1 and i put Datagrid1 on it and i want to change its column width and row hight ex: datagrid1.column(0).width=200 datagrid1.row(0).width=100 or datagrid1.allcolumnwidth=200
3
by: Sean | last post by:
How do I change the width of a Datagrid column programatically to make it look better when displayed (no gray area after columns). Thanks
3
by: Aziz | last post by:
1. I have a shopping basket DataGrid with a list of products. What I want to do is when the user clicks on a row, a button will become visible/be created that allows user to edit the quantity. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.