473,587 Members | 2,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

My TableStyle Is Not Working

I have a bound datagrid that has data but the formatting from the TableStyle
is not affecting the appearence of the grid. Code below.

Private Sub BindDataGrid()
Try
dgActiveAdj.Tab leStyles.Clear( )

dgtsAdj = New DataGridTableSt yle
dgtsAdj.Mapping Name = "UTILITY.UtilTo Adjust"

' This is a valid DataRelation of dsDataSet

With dgActiveAdj
.DataSource = dsDataSet
.DataMember = "UTILITY.UtilTo Adjust"
.AllowSorting = True
End With

dgtsAdj.Mapping Name = "UTILITY.UtilTo Adjust"

Dim grdColStyle1 As New DataGridTextBox Column
With grdColStyle1
.HeaderText = "Adjustment Name"
.MappingName = "UTILITY.UtilTo Adjust.Adjustme ntName"
dgtsAdj.GridCol umnStyles.Add(g rdColStyle1)
End With

grdColStyle1 = New DataGridTextBox Column
With grdColStyle1
.HeaderText = "Amount"
.MappingName = "UTILITY.UtilTo Adjust.Adjustme nt"
dgtsAdj.GridCol umnStyles.Add(g rdColStyle1)
End With

grdColStyle1 = New DataGridTextBox Column
With grdColStyle1
.HeaderText = "Start Data"
.MappingName = "UTILITY.UtilTo Adjust.AdjStart Date"
dgtsAdj.GridCol umnStyles.Add(g rdColStyle1)
End With

grdColStyle1 = New DataGridTextBox Column
With grdColStyle1
.HeaderText = "End Data"
.MappingName = "UTILITY.UtilTo Adjust.AdjEndDa te"
dgtsAdj.GridCol umnStyles.Add(g rdColStyle1)
End With

dgActiveAdj.Tab leStyles.Add(dg tsAdj)
dgActiveAdj.Tab leStyles(0).Rea dOnly = True

Catch ex As Exception
MessageBox.Show (ex.Source.ToSt ring & " - " & ex.Message,
Application.Pro ductName, _
MessageBoxButto ns.OK, MessageBoxIcon. Error)
End Try

End Sub
Nov 20 '05 #1
4 2668
Hi,

Two things. 1 When filling the dataset specify the name. 2 you did
not add the gridcolumnstyle s to the table style.

Here is an example of how to setup a grid.
Dim ts As New DataGridTableSt yle

ts.MappingName = "InvoiceDat a"

Dim colDescription As New DataGridTextBox Column

With colDescription

..MappingName = "Descriptio n"

..HeaderText = "Descriptio n"

..Width = 280

..NullText = ""

End With

Dim colQty As New DataGridTextBox Column

With colQty

..MappingName = "Quantity"

..HeaderText = "Qty"

..Width = 50

End With

Dim cm As CurrencyManager = CType(Me.Bindin gContext(dvClie nt),
CurrencyManager )

Dim pd As System.Componen tModel.Property Descriptor =
cm.GetItemPrope rties()("Each")

Dim colEach As New DataGridTextBox Column(pd, "C")

With colEach

..MappingName = "Each"

..HeaderText = "Each"

..Width = 50

End With

Dim colPrice As New DataGridTextBox Column(pd, "C")

With colPrice

..MappingName = "Price"

..HeaderText = "Price"

..Width = 50

End With

ts.GridColumnSt yles.Add(colDes cription)

ts.GridColumnSt yles.Add(colQty )

ts.GridColumnSt yles.Add(colEac h)

ts.GridColumnSt yles.Add(colPri ce)

dgInvoiceData.T ableStyles.Add( ts)

ts = Nothing

colPrice = Nothing

colEach = Nothing

colQty = Nothing

colDescription = Nothing

Ken
------------------
"Ken Powers" <KP*****@wppisy s.org> wrote in message
news:u4******** ******@TK2MSFTN GP12.phx.gbl...
I have a bound datagrid that has data but the formatting from the TableStyle is not affecting the appearence of the grid. Code below.

Private Sub BindDataGrid()
Try
dgActiveAdj.Tab leStyles.Clear( )

dgtsAdj = New DataGridTableSt yle
dgtsAdj.Mapping Name = "UTILITY.UtilTo Adjust"

' This is a valid DataRelation of dsDataSet

With dgActiveAdj
.DataSource = dsDataSet
.DataMember = "UTILITY.UtilTo Adjust"
.AllowSorting = True
End With

dgtsAdj.Mapping Name = "UTILITY.UtilTo Adjust"

Dim grdColStyle1 As New DataGridTextBox Column
With grdColStyle1
.HeaderText = "Adjustment Name"
.MappingName = "UTILITY.UtilTo Adjust.Adjustme ntName"
dgtsAdj.GridCol umnStyles.Add(g rdColStyle1)
End With

grdColStyle1 = New DataGridTextBox Column
With grdColStyle1
.HeaderText = "Amount"
.MappingName = "UTILITY.UtilTo Adjust.Adjustme nt"
dgtsAdj.GridCol umnStyles.Add(g rdColStyle1)
End With

grdColStyle1 = New DataGridTextBox Column
With grdColStyle1
.HeaderText = "Start Data"
.MappingName = "UTILITY.UtilTo Adjust.AdjStart Date"
dgtsAdj.GridCol umnStyles.Add(g rdColStyle1)
End With

grdColStyle1 = New DataGridTextBox Column
With grdColStyle1
.HeaderText = "End Data"
.MappingName = "UTILITY.UtilTo Adjust.AdjEndDa te"
dgtsAdj.GridCol umnStyles.Add(g rdColStyle1)
End With

dgActiveAdj.Tab leStyles.Add(dg tsAdj)
dgActiveAdj.Tab leStyles(0).Rea dOnly = True

Catch ex As Exception
MessageBox.Show (ex.Source.ToSt ring & " - " & ex.Message,
Application.Pro ductName, _
MessageBoxButto ns.OK, MessageBoxIcon. Error)
End Try

End Sub

Nov 20 '05 #2
Ken,

I did add my GridColumnStyle s to my TableStyle.

dgtsAdj being my TablesStyle.

Anything else you can think of.

Ken
Nov 20 '05 #3
Ken,

To answer number 1 this is how I'm filling my DataSet. This sub fires
before I try ti bind to my DataGrid.

Private Sub Get_Data()
Try

Dim sqlcmd = New SqlCommand("sel ect * from INPUT Order by CODE",
sqlConn)

daDataAdapter = New SqlDataAdapter
daDataAdapter.S electCommand = sqlcmd

dsDataSet = New DataSet
daDataAdapter.F ill(dsDataSet, "INPUT")
sqlcmd = New SqlCommand("sel ect * from Utility", sqlConn)
daDataAdapter = New SqlDataAdapter
daDataAdapter.S electCommand = sqlcmd

daDataAdapter.F ill(dsDataSet, "Utility")

sqlcmd = New SqlCommand("sel ect * from ratefil", sqlConn)
daDataAdapter = New SqlDataAdapter
daDataAdapter.S electCommand = sqlcmd

daDataAdapter.F ill(dsDataSet, "ratefil")

sqlcmd = New SqlCommand("sel ect * from ActiveAdjust", sqlConn)
daDataAdapter = New SqlDataAdapter
daDataAdapter.S electCommand = sqlcmd

daDataAdapter.F ill(dsDataSet, "ActiveAdju st")

Dim dr As DataRelation = New _
DataRelation("U tilToInput",
dsDataSet.Table s("Utility").Co lumns.Item("cod e"),
dsDataSet.Table s("Input").Colu mns.Item("code" ))
dsDataSet.Relat ions.Add(dr)
dr = New DataRelation("U tilToAdjust",
dsDataSet.Table s("Utility").Co lumns.Item("cod e"),
dsDataSet.Table s("ActiveAdjust ").Columns.Item ("Code"))
dsDataSet.Relat ions.Add(dr)

Set_Update_Comm and()

Catch ex As Exception
MessageBox.Show (ex.Source.ToSt ring & " - " & ex.Message,
Application.Pro ductName, _
MessageBoxButto ns.OK, MessageBoxIcon. Error)
End Try
End Sub
Nov 20 '05 #4
Hi,

You can only bind a tablestyle to a table not a datareleation. If
you had a master and a detail grid on your form you could use a
datareleation to keep them in sync. Here is an link to an example.

http://msdn.microsoft.com/library/de...indowsForm.asp

Ken
------------------------------------------
"Ken Powers" <KP*****@wppisy s.org> wrote in message
news:u4******** ******@TK2MSFTN GP12.phx.gbl...
I have a bound datagrid that has data but the formatting from the TableStyle is not affecting the appearence of the grid. Code below.

Private Sub BindDataGrid()
Try
dgActiveAdj.Tab leStyles.Clear( )

dgtsAdj = New DataGridTableSt yle
dgtsAdj.Mapping Name = "UTILITY.UtilTo Adjust"

' This is a valid DataRelation of dsDataSet

With dgActiveAdj
.DataSource = dsDataSet
.DataMember = "UTILITY.UtilTo Adjust"
.AllowSorting = True
End With

dgtsAdj.Mapping Name = "UTILITY.UtilTo Adjust"

Dim grdColStyle1 As New DataGridTextBox Column
With grdColStyle1
.HeaderText = "Adjustment Name"
.MappingName = "UTILITY.UtilTo Adjust.Adjustme ntName"
dgtsAdj.GridCol umnStyles.Add(g rdColStyle1)
End With

grdColStyle1 = New DataGridTextBox Column
With grdColStyle1
.HeaderText = "Amount"
.MappingName = "UTILITY.UtilTo Adjust.Adjustme nt"
dgtsAdj.GridCol umnStyles.Add(g rdColStyle1)
End With

grdColStyle1 = New DataGridTextBox Column
With grdColStyle1
.HeaderText = "Start Data"
.MappingName = "UTILITY.UtilTo Adjust.AdjStart Date"
dgtsAdj.GridCol umnStyles.Add(g rdColStyle1)
End With

grdColStyle1 = New DataGridTextBox Column
With grdColStyle1
.HeaderText = "End Data"
.MappingName = "UTILITY.UtilTo Adjust.AdjEndDa te"
dgtsAdj.GridCol umnStyles.Add(g rdColStyle1)
End With

dgActiveAdj.Tab leStyles.Add(dg tsAdj)
dgActiveAdj.Tab leStyles(0).Rea dOnly = True

Catch ex As Exception
MessageBox.Show (ex.Source.ToSt ring & " - " & ex.Message,
Application.Pro ductName, _
MessageBoxButto ns.OK, MessageBoxIcon. Error)
End Try

End Sub

Nov 20 '05 #5

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

Similar topics

0
1596
by: Herve MAILLARD | last post by:
I have added aTableStyle to my Datagrid. The table linked to the datagrid display a boolean field. Before apply the TableStyle,the datagrid was displaying a Checkbox. Since I have apply the TableStyle, the datagrid display True/False in the cell? How can I do to display the Checkbox ?
2
1297
by: tomp | last post by:
Hi, This is driving me crazy. Once the TableStyle is added (last line) the datagrid comes up blank. If I comment it out, the data grid shows the column names from the dataset. I must be doing something out of sequence Thanks in advance for help provided To ------- Dim dsComputerFileDetails As New DataSet(
1
993
by: Agnes | last post by:
For single datagrid, i can bind the table very well, I can add myGridTablestyle to the datagrid. However, after i set the relations before dgParents and dgDetails. It ignore my tablestyle(). It shows all the data and it allow the user to add the new row.. I understand that I can't use dataview ,right ? (e.g dgParents.datasource =...
2
1579
by: KC | last post by:
Why would the code below fail? I'm making a tablestyle, which works fine. I test to see if the style already exist for this datagrid, if it does, remove it before adding the new version. What I don't understand is the 'Contains' method. I get different answers depending on whether I use: dgNC.TableStyles.Contains(dgtsNC) or ...
1
1285
by: Bob | last post by:
is it possible to remove just a specific tablestyle and keep anyothers that may exist? I've got the folowing code: Dim TS As New DataGridTableStyle TS.MappingName = "ABQTG0UN" ...... Datagrid1.TableStyles.Add(TS)
3
1806
by: Reza G. | last post by:
I am creating a window forms, and placed a datagrid on it. Set the DataSource and DataMember, and I get all the column in the table (relation) shown. I used TableStyles of the DataGrid and add a new member. I set its MappingName same as DataMember. Then I use GridColumnStyle and add the columns I needed. But when I run the application all...
2
1094
by: Mac via DotNetMonster.com | last post by:
Hi all, I have a datagrid on a form which I have set the datasource (through the form designer) to be a dataset that I have added to the form, also through the form designer. I then have added a tablestyle which is mapped to the relevant table in the dataset that is associated to the datagrid and I get pre-drawn column headings for my...
0
963
by: Kmistic | last post by:
I have created the datagrid in the following link http://support.microsoft.com/default.aspx?scid=kb;en-us;836672 When i try to apply a tablestyle i get an exeption stating that the data grid tablestyle collection already contains a table style with the same mapping name. Parameter Name: Table Is there a trick to using tablestyles with...
0
917
by: AliRezaGoogle | last post by:
Hi I have a problem with tablestyle of datagrid: First I create a new tablestyle in form designer. Then I add some gridecolumnstyle to the new tablestyle. I fill all MappingNames with correct values. But in run-time I do not see my designed style on the grid. What is wrong?
0
7918
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...
0
7843
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8206
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. ...
0
8340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8220
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...
1
5713
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
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...
1
2353
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
0
1185
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...

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.