473,795 Members | 2,452 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGridTableSt yle help

1 New Member
I have a drop down box with a list of tables from a SQL CE database running on Windows Mobile 5, and once a user selects a table, all the data is bound to a datagrid. Now I'm trying to format the datagrid using a datagridtablest yle. It works for the first table, but if a user selects another table, it errors out. As a test I have the two functions CreateDataTable which creates a table with data and SetupTableStyle s which sets up the datagridtablest yle. The button calls CreateDataTable and then SetupTableStyle s. On the second press it throws an error of "Value does not fall within the expected range" when it tries to add the first custom column in SetupTableStyle s. Any idea on why this would occur?

Private Sub SetupTableStyle s(ByVal data As DataTable)
Dim alternatingColo r As Color = SystemColors.Co ntrolDark

Dim table As New DataTable()
table = data

Dim dataGridCustomC olumn0 As New DataGridCustomT extBoxColumn
With dataGridCustomC olumn0
.Owner = Me.DataGrid1
.Format = "0##"
.FormatInfo = Nothing
.HeaderText = table.Columns(0 ).ColumnName
.MappingName = table.Columns(0 ).ColumnName
.Width = DataGrid1.Width * 10 / 100
.AlternatingBac kColor = alternatingColo r
.ReadOnly = True
End With
DataGridTableSt yle1.GridColumn Styles.Add(data GridCustomColum n0)

Dim dataGridCustomC olumn1 As New DataGridCustomT extBoxColumn()
With dataGridCustomC olumn1
.Owner = Me.DataGrid1
.HeaderText = table.Columns(1 ).ColumnName
.MappingName = table.Columns(1 ).ColumnName
.NullText = ""
.Width = Me.DataGrid1.Wi dth * 40 / 100 ' 40%
.Alignment = HorizontalAlign ment.Right
.AlternatingBac kColor = alternatingColo r
End With
Me.DataGridTabl eStyle1.GridCol umnStyles.Add(d ataGridCustomCo lumn1)

Me.DataGridTabl eStyle1.Mapping Name = "Route"
Me.DataGrid1.Da taSource = table
End Sub

Private Sub CreateDataTable (ByVal num As Integer)
Dim Route As New DataTable("Rout e")
Route.Columns.A dd("Folio", GetType(String) )
Route.Columns.A dd("Address", GetType(String) )

For i As Integer = 0 To num
Route.Rows.Add( "test", "test1")
Next

SetupTableStyle s(Route)
End Sub
Aug 28 '07 #1
0 1222

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2265
by: Floela | last post by:
I want to set a the MappingName of a DataGridTableStyle to "ArrayList" in an ASP.NET page, but the class is stored in the System.Windows.Forms namespace. It won't let me import the namespace at the top of my page (The type or namespace name 'Windows' does not exist in the class or namespace 'System'). How do I create a DataGridTableStyle in ASP.NET?
2
3455
by: Carlos | last post by:
Does DataGridTableStyle work in ASP.net ? any time I'm tring to define a varibale lke DataGridTableStyle MyStyle = new DataGridTableStyle(); it give me "The Type or name sapce 'DataGridTableStyle 'could not be found" also I have the following at the begining of the program.. using System;
2
3130
by: Scott | last post by:
Hi all. A few days ago i ask this question and got a good quick response. I tried out what they said and it worked. However I have now come to try the same thing in another program and it does not seem to be working.
2
1766
by: Carlos | last post by:
Does DataGridTableStyle work in ASP.net ? any time I'm tring to define a varibale lke DataGridTableStyle MyStyle = new DataGridTableStyle(); it give me "The Type or name sapce 'DataGridTableStyle 'could not be found" also I have the following at the begining of the program.. using System;
2
2110
by: kerpal | last post by:
Hi all, 1. Could anyone pls clarify the difference between setting the AlternatingBackColor property in DataGridTableStyle and in DataGrid?? 2. How come BackColor and AlternatingBackColor are both associated with the ODD-numbered rows of the grid as stated in msdn?? Thank you and happy new year!!
2
2425
by: Brett Romero | last post by:
I can't find what exactly I'm doing wrong that the following DataGridTableStyle is not working on my table. The result set returns 21 columns. I'm only formatting 5 via the TableStyle. I thought maybe the problem was I had more columns being put into the DataGrid than I was formatting. I then created a new table and adding only the five mapped columns to it. That didn't help either. I'm hiding column 3 because I need its value but...
4
5846
by: Brett Romero | last post by:
I have the following DataGridTableStyle: DataGridTableStyle gridTableStyle = new DataGridTableStyle(); gridTableStyle.MappingName = "myStyle"; DataGridTextBoxColumn dgsc = new DataGridTextBoxColumn(); dgsc.MappingName = "FirstName"; dgsc.HeaderText = "First Name"; dgsc.Width = 30; dgsc.TextBox.Enabled = false; gridTableStyle.GridColumnStyles.Add(dgsc);
3
4300
by: nita | last post by:
I'm just starting out, and it's incredibly frustrating when I see sample code and then try to implement it. Case in point. I'm populating a collection then binding it to a datagrid. That works great. The problem is the columns are in the wrong order. OK. I'll use the datagridtablestyle. But when I add the following statement; Dim tableStyle As New DataGridTableStyle I get an error when I build the project;
7
12631
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's the background for my question... Before I switched my application over to the Fx 2.0, I used a DataGrid to display my data. I would store different DataGridTableStyles (each one with a custom set of columns) in the DataGrid.TableStyles property...
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10437
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10164
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
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 we have to send another system
2
3723
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.