473,804 Members | 3,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems setting up datagrid

I am attempting to set up a datagrid that will 1) display a subset of data
from a SQL Stored Procedure in a different order form how SQL returns it,
and 2) display 3 of the columns using pulldowns. I have gotten code for
both from the www.syncfusion.com site, but am having trouble making them
work. Below is the relevant code:
' Setup the permissions grid
' Fill the dataset of permissions
Dim dt As DataTable = dsUserData.Tabl es(0)
' Remove the table columns we don't want to have in the grid
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(0)
dt.Columns.Remo veAt(0)

Dim tableStyle As New DataGridTableSt yle
tableStyle.Mapp ingName = "permission s"

' Setup the Subsystems column
Dim TextCol As New DataGridTextBox Column
TextCol.Mapping Name = dt.Columns(3).C olumnName
TextCol.HeaderT ext = dt.Columns(3).C olumnName
tableStyle.Grid ColumnStyles.Ad d(TextCol)

' Setup the permissions columns
Dim i As Integer
For i = 0 To 2
Dim ComboTextCol As New DataGridComboBo xColumn
ComboTextCol.Ma ppingName = dt.Columns(i).C olumnName
ComboTextCol.He aderText = dt.Columns(i).C olumnName
ComboTextCol.Wi dth = 120
ComboTextCol.Co lumnComboBox.It ems.Clear()
ComboTextCol.Co lumnComboBox.It ems.Add("0")
ComboTextCol.Co lumnComboBox.It ems.Add("1")
ComboTextCol.Co lumnComboBox.It ems.Add("3")
ComboTextCol.Co lumnComboBox.It ems.Add("7")
' ComboTextCol.Co lumnComboBox.It ems.Add("No Access")
' ComboTextCol.Co lumnComboBox.It ems.Add("Guest" )
' ComboTextCol.Co lumnComboBox.It ems.Add("Operat or")
' ComboTextCol.Co lumnComboBox.It ems.Add("Manage r")

tableStyle.Pref erredRowHeight =
ComboTextCol.Co lumnComboBox.He ight + 2

tableStyle.Grid ColumnStyles.Ad d(ComboTextCol)
Next

grdPermissions. TableStyles.Cle ar()
grdPermissions. TableStyles.Add (tableStyle)
grdPermissions. DataSource = dt
' MsgBox(grdPermi ssions.TableSty les(0).MappingN ame)

dsUserData is already setup and is being used to also fill some text boxes
on the form, so I know that it is fine, and I have as part of my project the
DataGridComboBo xColumn.vb class that is defined in the syncfusion web site.
From what I have been able to find, the "Setup Subsystems" section should
make that column be the first in the grid because it is defined first in the
TableStyle, but it is showing up last (as it was in the original dataset).
Also, the 3 column that are setup under "Setup the permissions columns" are
showing up as simple text boxes, not as combo boxes. Can anyone see what I
am doing wrong here?

TIA
Ron L

Nov 21 '05 #1
2 2688
Hi,

Sounds like it is not using your table style. The mapping name is
wrong. Try this instead.
tableStyle.Mapp ingName = dt.tablename.to string
Ken
--------------------------
"Ron L" <ro**@bogus.Add ress.com> wrote in message
news:uQ******** *****@TK2MSFTNG P10.phx.gbl...
I am attempting to set up a datagrid that will 1) display a subset of data
from a SQL Stored Procedure in a different order form how SQL returns it,
and 2) display 3 of the columns using pulldowns. I have gotten code for
both from the www.syncfusion.com site, but am having trouble making them
work. Below is the relevant code:
' Setup the permissions grid
' Fill the dataset of permissions
Dim dt As DataTable = dsUserData.Tabl es(0)
' Remove the table columns we don't want to have in the grid
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(0)
dt.Columns.Remo veAt(0)

Dim tableStyle As New DataGridTableSt yle
tableStyle.Mapp ingName = "permission s"

' Setup the Subsystems column
Dim TextCol As New DataGridTextBox Column
TextCol.Mapping Name = dt.Columns(3).C olumnName
TextCol.HeaderT ext = dt.Columns(3).C olumnName
tableStyle.Grid ColumnStyles.Ad d(TextCol)

' Setup the permissions columns
Dim i As Integer
For i = 0 To 2
Dim ComboTextCol As New DataGridComboBo xColumn
ComboTextCol.Ma ppingName = dt.Columns(i).C olumnName
ComboTextCol.He aderText = dt.Columns(i).C olumnName
ComboTextCol.Wi dth = 120
ComboTextCol.Co lumnComboBox.It ems.Clear()
ComboTextCol.Co lumnComboBox.It ems.Add("0")
ComboTextCol.Co lumnComboBox.It ems.Add("1")
ComboTextCol.Co lumnComboBox.It ems.Add("3")
ComboTextCol.Co lumnComboBox.It ems.Add("7")
' ComboTextCol.Co lumnComboBox.It ems.Add("No Access")
' ComboTextCol.Co lumnComboBox.It ems.Add("Guest" )
' ComboTextCol.Co lumnComboBox.It ems.Add("Operat or")
' ComboTextCol.Co lumnComboBox.It ems.Add("Manage r")

tableStyle.Pref erredRowHeight =
ComboTextCol.Co lumnComboBox.He ight + 2

tableStyle.Grid ColumnStyles.Ad d(ComboTextCol)
Next

grdPermissions. TableStyles.Cle ar()
grdPermissions. TableStyles.Add (tableStyle)
grdPermissions. DataSource = dt
' MsgBox(grdPermi ssions.TableSty les(0).MappingN ame)

dsUserData is already setup and is being used to also fill some text boxes
on the form, so I know that it is fine, and I have as part of my project the
DataGridComboBo xColumn.vb class that is defined in the syncfusion web site.
From what I have been able to find, the "Setup Subsystems" section should
make that column be the first in the grid because it is defined first in the
TableStyle, but it is showing up last (as it was in the original dataset).
Also, the 3 column that are setup under "Setup the permissions columns" are
showing up as simple text boxes, not as combo boxes. Can anyone see what I
am doing wrong here?

TIA
Ron L


Nov 21 '05 #2
Ken
Thanks for the response. I tried that change and get the following
error message when I open the form:

An unhandled exception of type 'System.Invalid CastException'
occurred in system.windows. forms.dll
Additional information: Specified cast is not valid.

I don't know where the table name would come from, but the contents of this
dataset is the results set returned from calling a SQL 2k stored procedure
that does a select on a number of tables using JOIN statements. Do you have
any further suggestions?

Thanks,
Ron L

"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi,

Sounds like it is not using your table style. The mapping name is
wrong. Try this instead.
tableStyle.Mapp ingName = dt.tablename.to string
Ken
--------------------------
"Ron L" <ro**@bogus.Add ress.com> wrote in message
news:uQ******** *****@TK2MSFTNG P10.phx.gbl...
I am attempting to set up a datagrid that will 1) display a subset of data
from a SQL Stored Procedure in a different order form how SQL returns it,
and 2) display 3 of the columns using pulldowns. I have gotten code for
both from the www.syncfusion.com site, but am having trouble making them
work. Below is the relevant code:
' Setup the permissions grid
' Fill the dataset of permissions
Dim dt As DataTable = dsUserData.Tabl es(0)
' Remove the table columns we don't want to have in the grid
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(5)
dt.Columns.Remo veAt(0)
dt.Columns.Remo veAt(0)

Dim tableStyle As New DataGridTableSt yle
tableStyle.Mapp ingName = "permission s"

' Setup the Subsystems column
Dim TextCol As New DataGridTextBox Column
TextCol.Mapping Name = dt.Columns(3).C olumnName
TextCol.HeaderT ext = dt.Columns(3).C olumnName
tableStyle.Grid ColumnStyles.Ad d(TextCol)

' Setup the permissions columns
Dim i As Integer
For i = 0 To 2
Dim ComboTextCol As New DataGridComboBo xColumn
ComboTextCol.Ma ppingName = dt.Columns(i).C olumnName
ComboTextCol.He aderText = dt.Columns(i).C olumnName
ComboTextCol.Wi dth = 120
ComboTextCol.Co lumnComboBox.It ems.Clear()
ComboTextCol.Co lumnComboBox.It ems.Add("0")
ComboTextCol.Co lumnComboBox.It ems.Add("1")
ComboTextCol.Co lumnComboBox.It ems.Add("3")
ComboTextCol.Co lumnComboBox.It ems.Add("7")
' ComboTextCol.Co lumnComboBox.It ems.Add("No Access")
' ComboTextCol.Co lumnComboBox.It ems.Add("Guest" )
' ComboTextCol.Co lumnComboBox.It ems.Add("Operat or")
' ComboTextCol.Co lumnComboBox.It ems.Add("Manage r")

tableStyle.Pref erredRowHeight =
ComboTextCol.Co lumnComboBox.He ight + 2

tableStyle.Grid ColumnStyles.Ad d(ComboTextCol)
Next

grdPermissions. TableStyles.Cle ar()
grdPermissions. TableStyles.Add (tableStyle)
grdPermissions. DataSource = dt
' MsgBox(grdPermi ssions.TableSty les(0).MappingN ame)

dsUserData is already setup and is being used to also fill some text boxes
on the form, so I know that it is fine, and I have as part of my project
the
DataGridComboBo xColumn.vb class that is defined in the syncfusion web
site.
From what I have been able to find, the "Setup Subsystems" section should
make that column be the first in the grid because it is defined first in
the
TableStyle, but it is showing up last (as it was in the original dataset).
Also, the 3 column that are setup under "Setup the permissions columns"
are
showing up as simple text boxes, not as combo boxes. Can anyone see what
I
am doing wrong here?

TIA
Ron L

Nov 21 '05 #3

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

Similar topics

3
4277
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found several examples on the web. They all seem to have problems, though that I've been unable to resolve. The most promising example I have found is at:
0
1775
by: Shravan | last post by:
Hi, I have a Windows Forms Custom DataGrid, which is put in a usercontrol, which on setting DataSource is setting focus to grid. The call stack for setting the focus is as follows. This is not happened always whenever DataSource is set, only called sometimes, in a series of setting DataSource, I could get this setting focus only one time . Can anybody help me how to stop this one. system.windows.forms.dll!
1
2252
by: Phil Townsend | last post by:
I am using the ItemDataBound event of a Datagrid to color code table cells according to data returned from a SQL stored procedure. At first everything worked, but then I decided to customize the datagrid by setting autogenerate columns to 'false' and defining my own column names (in the aspx page), etc. The ItemDataBound event still fires but I cannot get it to return the same values. In fact, after writing test code to examine all of the...
3
2631
by: simchajoy2000 | last post by:
Hi, I have been working with datagrids a lot in the past two weeks and I am running across a lot of problems. Maybe there is no way around these problems but I hope there are and someone out there can advise me on how to do it. 1. The biggest problem I am finding is that the datagrid does not update the datagrid.datasource very well. When a new row is created in the datagrid it may or may not be created in the datasource as
5
4744
by: Dennis | last post by:
I have a class that inherits from DataGrid. I can set the rowheights in a DataGrid by tappig into the "get_Datagridrows" method. However, this does not work for classes that inherit from DataGrid. Anyone know how to do this on derived classes? I find it apalling that Microsoft provided a DataGrid that is so inflexible! -- Dennis in Houston
2
1594
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 dgNC.TableStyles.Contains(dgtsNC.MappingName) I guess I just don't get this tablestyles thing.
18
4636
by: james | last post by:
Hi, I am loading a CSV file ( Comma Seperated Value) into a Richtext box. I have a routine that splits the data up when it hits the "," and then copies the results into a listbox. The data also has some different characters in it that I am trying to remove. The small a with two dots over it and the small y with two dots over it. Here is my code so far to remove the small y: Private Sub Button2_Click(ByVal sender As System.Object, ByVal...
0
1206
by: bh | last post by:
I'm trying to edit data in a datagrid through a dropdown list with different id/text values. The problem comes in when I click the edit button & nothing appears to be happening. Did I do something wrong in the EditItemTemplate or should I be binding, somehow, separately in the vb code? Please view my code, below, and the notes in green for clarification of what I've done, and what is/is not working, here. Thanks in advance.
4
9927
by: Blackbrand | last post by:
I'll start off with what i'm trying to do: i want to search my data programmatically and then jump to the row in the datagrid. My data will almost allways go out of the datagrids bounds so if the found result is not on screen at the time i want to 'scroll' to the result. sounds simple enough right? Some things i've tried to get the datagrid to do what i want:
2
2178
by: ree321 | last post by:
I tried moving an ASP.net project form 1.1 to 2.0. But I am having problems with getting the OnItemDataBound function to run for a datagrid, in 2.0. It only gets called up if AutoGenerateColumns is set to false. Is there anyway around this? Then I tried changing the datagrid to GridView and still I am having trouble getting the function to run in code behind using: Sub databoundGeneral(ByVal s As Object, ByVal e As
0
10586
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...
0
10338
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
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
6856
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
5525
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
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
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
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.