473,834 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datatable Dataset Datagrid help

Hi I am somewhat confused, I am new at VB.net
I use XML data,
I have a datagrid,
I created a datatable so that I can create a custom format like true is this
graphic false is this graphic and others.
One of the custom format is as follows:
dsmessages_dt.C olumns.Add("Ima ge", GetType(Image))
I had a problem of when I used a checkbox in the grid that was bound to the
datatable that it would not update my dataset. So I created another datagrid
and tied it to the dataset and relicated changes made in the first datagrid
bound to the datatable to the second grid bound to the dataset using the
index of both tables.

Then I couldn't filter the dataset if I filter the dataset it doesnt filter
through to the datatable.

I realize there should be an easier way to access the dataset without having
to create another datagrid bound to the dataset.
If you could kindly look at my code as I have lots of books and done lots of
research and there is no clear explanation on how to access the dataset so
ill post my code. I use a few components but maybe someone can explain how to
access things properly instead of blowing up my program with duplicate data.

Here is what I have:
XML Data filename: dsmessages.xml
<?xml version="1.0" standalone="yes "?>
<members>
<member>
<msg_notifycode >0</msg_notifycode>
<msg_read>Tru e</msg_read>
<msg_type>Hig h</msg_type>
<msg_link>www.g oogle.com</msg_link>
<msg_title>Re ad Message</msg_title>
<msg_message>Cu stomer needs help with new settings</msg_message>
<msg_to>All Users</msg_to>
<msg_date>01/05/2005</msg_date>
</member>
<member>
<msg_notifycode >1</msg_notifycode>
<msg_read>false </msg_read>
<msg_type>Hig h</msg_type>
<msg_link>www.s olarblu.com</msg_link>
<msg_title>Re ad Message</msg_title>
<msg_message>Cu stomer needs help with new settings2</msg_message>
<msg_to>All Users</msg_to>
<msg_date>01/05/2005</msg_date>
</member>
</members>
Code:

Private Sub button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles button1.Click

Me.refToB.notif iedoff = True

'Me.Close()

'Me.refTomainfo rm.frm_Closed()

Me.refToB.frm_C losed()

Me.ActiveForm.C lose()

End Sub

Private Sub taskbarmessages _Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load

' create custom style for links

Dim cs As CellStyle = todo_datagrid.S tyles.Add("NewL ink")

cs.Font = New Font(todo_datag rid.Font, FontStyle.Under line)

cs.ForeColor = Color.Blue

cs = todo_datagrid.S tyles.Add("OldL ink")

cs.Font = New Font(todo_datag rid.Font, FontStyle.Under line)

cs.ForeColor = Color.Purple

cs = todo_datagrid.S tyles.Add("bool ")

cs.DataType = Type.GetType("S ystem.Boolean")

cs.ImageAlign = ImageAlignEnum. CenterCenter

' create data source

dsmessages_dt.C olumns.Add("che ck", GetType(Boolean ))

dsmessages_dt.C olumns.Add("Ima ge", GetType(Image))

dsmessages_dt.C olumns.Add("Lin k", GetType(Hyperli nk))

dsmessages_dt.C olumns("Link"). ReadOnly = True

dsmessages_dt.C olumns.Add("Des cription", GetType(String) )

dsmessages_data .ReadXml("messa ges.xml")

Dim dvmessages As DataView = New
DataView(dsmess ages_data.Table s(dsmessages_da ta.Tables(0).To String))

todo_datagridte mp.DataSource = dvmessages

'dvmessages.Row Filter = "msg_read <> true and msgflag_updated <> true"

Dim obj As Object = New Object(3) {}

Dim i As Integer

For i = 0 To 5 - 1

Next

' bind the grid to the data source and turn on owner-drawing

todo_datagrid.D ataSource = dsmessages_dt

todo_datagrid.D rawMode = DrawModeEnum.Ow nerDraw

todo_datagrid.C ols(0).Width = 20

todo_datagrid.C ols(1).Width = 20

todo_datagrid.C ols(1).AllowEdi ting = False

todo_datagrid.C ols(2).AllowEdi ting = False

todo_datagrid.C ols(3).AllowEdi ting = False

For i = 0 To dsmessages_data .Tables(0).Rows .Count - 1

obj(0) = dsmessages_data .Tables(0).Rows (i).Item("msg_r ead")

obj(1) =
ImageList1.Imag es(dsmessages_d ata.Tables(0).R ows(i).Item("ms g_notifycode"))

obj(2) = New
Hyperlink(dsmes sages_data.Tabl es(0).Rows(i).I tem("msg_title" ),
dsmessages_data .Tables(0).Rows (i).Item("msg_l ink"))

obj(3) = dsmessages_data .Tables(0).Rows (i).Item("msg_m essage")

If dsmessages_data .Tables(0).Rows (i).Item("msg_r ead") = True Then

dsmessages_dt.R ows.Add(obj)

End If

Next

Display_todo.Se lectedIndex = 0

Dim dvmessages2 As DataView = dsmessages_dt.D efaultView

End Sub

Sub savechanges()

dsmessages_data .WriteXml("mess ages.xml")
End Sub

Private Sub CheckBox2_Check edChanged(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles CheckBox2.Check edChanged

Dim obj As Object = New Object(3) {}

Dim i As Integer

For i = 0 To dsmessages_data .Tables(0).Rows .Count - 1

todo_datagridte mp.Item(i, 1) = "True"

todo_datagrid.I tem(i, 0) = todo_datagridte mp.Item(i, 1)

Next

Call savechanges()

End Sub
Nov 21 '05 #1
3 2523
Hi,

Can you mabye first paste your code in a notebook, than copy it back and
than paste it in the message.
With outlook express your code is almost unreadable.

Cor
Nov 21 '05 #2
Hi,

What kind of datagrid are you using?

Ken
-------------------
"Datatable Dataset Datagrid help" <Datatable Dataset Datagrid
he**@discussion s.microsoft.com> wrote in message
news:0A******** *************** ***********@mic rosoft.com...
Hi I am somewhat confused, I am new at VB.net
I use XML data,
I have a datagrid,
I created a datatable so that I can create a custom format like true is this
graphic false is this graphic and others.
One of the custom format is as follows:
dsmessages_dt.C olumns.Add("Ima ge", GetType(Image))
I had a problem of when I used a checkbox in the grid that was bound to the
datatable that it would not update my dataset. So I created another datagrid
and tied it to the dataset and relicated changes made in the first datagrid
bound to the datatable to the second grid bound to the dataset using the
index of both tables.

Then I couldn't filter the dataset if I filter the dataset it doesnt filter
through to the datatable.

I realize there should be an easier way to access the dataset without having
to create another datagrid bound to the dataset.
If you could kindly look at my code as I have lots of books and done lots of
research and there is no clear explanation on how to access the dataset so
ill post my code. I use a few components but maybe someone can explain how
to
access things properly instead of blowing up my program with duplicate data.

Here is what I have:
XML Data filename: dsmessages.xml
<?xml version="1.0" standalone="yes "?>
<members>
<member>
<msg_notifycode >0</msg_notifycode>
<msg_read>Tru e</msg_read>
<msg_type>Hig h</msg_type>
<msg_link>www.g oogle.com</msg_link>
<msg_title>Re ad Message</msg_title>
<msg_message>Cu stomer needs help with new settings</msg_message>
<msg_to>All Users</msg_to>
<msg_date>01/05/2005</msg_date>
</member>
<member>
<msg_notifycode >1</msg_notifycode>
<msg_read>false </msg_read>
<msg_type>Hig h</msg_type>
<msg_link>www.s olarblu.com</msg_link>
<msg_title>Re ad Message</msg_title>
<msg_message>Cu stomer needs help with new settings2</msg_message>
<msg_to>All Users</msg_to>
<msg_date>01/05/2005</msg_date>
</member>
</members>
Code:

Private Sub button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles button1.Click

Me.refToB.notif iedoff = True

'Me.Close()

'Me.refTomainfo rm.frm_Closed()

Me.refToB.frm_C losed()

Me.ActiveForm.C lose()

End Sub

Private Sub taskbarmessages _Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load

' create custom style for links

Dim cs As CellStyle = todo_datagrid.S tyles.Add("NewL ink")

cs.Font = New Font(todo_datag rid.Font, FontStyle.Under line)

cs.ForeColor = Color.Blue

cs = todo_datagrid.S tyles.Add("OldL ink")

cs.Font = New Font(todo_datag rid.Font, FontStyle.Under line)

cs.ForeColor = Color.Purple

cs = todo_datagrid.S tyles.Add("bool ")

cs.DataType = Type.GetType("S ystem.Boolean")

cs.ImageAlign = ImageAlignEnum. CenterCenter

' create data source

dsmessages_dt.C olumns.Add("che ck", GetType(Boolean ))

dsmessages_dt.C olumns.Add("Ima ge", GetType(Image))

dsmessages_dt.C olumns.Add("Lin k", GetType(Hyperli nk))

dsmessages_dt.C olumns("Link"). ReadOnly = True

dsmessages_dt.C olumns.Add("Des cription", GetType(String) )

dsmessages_data .ReadXml("messa ges.xml")

Dim dvmessages As DataView = New
DataView(dsmess ages_data.Table s(dsmessages_da ta.Tables(0).To String))

todo_datagridte mp.DataSource = dvmessages

'dvmessages.Row Filter = "msg_read <> true and msgflag_updated <>
true"

Dim obj As Object = New Object(3) {}

Dim i As Integer

For i = 0 To 5 - 1

Next

' bind the grid to the data source and turn on owner-drawing

todo_datagrid.D ataSource = dsmessages_dt

todo_datagrid.D rawMode = DrawModeEnum.Ow nerDraw

todo_datagrid.C ols(0).Width = 20

todo_datagrid.C ols(1).Width = 20

todo_datagrid.C ols(1).AllowEdi ting = False

todo_datagrid.C ols(2).AllowEdi ting = False

todo_datagrid.C ols(3).AllowEdi ting = False

For i = 0 To dsmessages_data .Tables(0).Rows .Count - 1

obj(0) = dsmessages_data .Tables(0).Rows (i).Item("msg_r ead")

obj(1) =
ImageList1.Imag es(dsmessages_d ata.Tables(0).R ows(i).Item("ms g_notifycode"))

obj(2) = New
Hyperlink(dsmes sages_data.Tabl es(0).Rows(i).I tem("msg_title" ),
dsmessages_data .Tables(0).Rows (i).Item("msg_l ink"))

obj(3) = dsmessages_data .Tables(0).Rows (i).Item("msg_m essage")

If dsmessages_data .Tables(0).Rows (i).Item("msg_r ead") = True
Then

dsmessages_dt.R ows.Add(obj)

End If

Next

Display_todo.Se lectedIndex = 0

Dim dvmessages2 As DataView = dsmessages_dt.D efaultView

End Sub

Sub savechanges()

dsmessages_data .WriteXml("mess ages.xml")
End Sub

Private Sub CheckBox2_Check edChanged(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles CheckBox2.Check edChanged

Dim obj As Object = New Object(3) {}

Dim i As Integer

For i = 0 To dsmessages_data .Tables(0).Rows .Count - 1

todo_datagridte mp.Item(i, 1) = "True"

todo_datagrid.I tem(i, 0) = todo_datagridte mp.Item(i, 1)

Next

Call savechanges()

End Sub

Nov 21 '05 #3
Component1 flexgrid
And for the other guy i pasted it from outlook first, then into newsgroups.

"Ken Tucker [MVP]" wrote:
Hi,

What kind of datagrid are you using?

Ken
-------------------
"Datatable Dataset Datagrid help" <Datatable Dataset Datagrid
he**@discussion s.microsoft.com> wrote in message
news:0A******** *************** ***********@mic rosoft.com...
Hi I am somewhat confused, I am new at VB.net
I use XML data,
I have a datagrid,
I created a datatable so that I can create a custom format like true is this
graphic false is this graphic and others.
One of the custom format is as follows:
dsmessages_dt.C olumns.Add("Ima ge", GetType(Image))
I had a problem of when I used a checkbox in the grid that was bound to the
datatable that it would not update my dataset. So I created another datagrid
and tied it to the dataset and relicated changes made in the first datagrid
bound to the datatable to the second grid bound to the dataset using the
index of both tables.

Then I couldn't filter the dataset if I filter the dataset it doesnt filter
through to the datatable.

I realize there should be an easier way to access the dataset without having
to create another datagrid bound to the dataset.
If you could kindly look at my code as I have lots of books and done lots of
research and there is no clear explanation on how to access the dataset so
ill post my code. I use a few components but maybe someone can explain how
to
access things properly instead of blowing up my program with duplicate data.

Here is what I have:
XML Data filename: dsmessages.xml
<?xml version="1.0" standalone="yes "?>
<members>
<member>
<msg_notifycode >0</msg_notifycode>
<msg_read>Tru e</msg_read>
<msg_type>Hig h</msg_type>
<msg_link>www.g oogle.com</msg_link>
<msg_title>Re ad Message</msg_title>
<msg_message>Cu stomer needs help with new settings</msg_message>
<msg_to>All Users</msg_to>
<msg_date>01/05/2005</msg_date>
</member>
<member>
<msg_notifycode >1</msg_notifycode>
<msg_read>false </msg_read>
<msg_type>Hig h</msg_type>
<msg_link>www.s olarblu.com</msg_link>
<msg_title>Re ad Message</msg_title>
<msg_message>Cu stomer needs help with new settings2</msg_message>
<msg_to>All Users</msg_to>
<msg_date>01/05/2005</msg_date>
</member>
</members>
Code:

Private Sub button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles button1.Click

Me.refToB.notif iedoff = True

'Me.Close()

'Me.refTomainfo rm.frm_Closed()

Me.refToB.frm_C losed()

Me.ActiveForm.C lose()

End Sub

Private Sub taskbarmessages _Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load

' create custom style for links

Dim cs As CellStyle = todo_datagrid.S tyles.Add("NewL ink")

cs.Font = New Font(todo_datag rid.Font, FontStyle.Under line)

cs.ForeColor = Color.Blue

cs = todo_datagrid.S tyles.Add("OldL ink")

cs.Font = New Font(todo_datag rid.Font, FontStyle.Under line)

cs.ForeColor = Color.Purple

cs = todo_datagrid.S tyles.Add("bool ")

cs.DataType = Type.GetType("S ystem.Boolean")

cs.ImageAlign = ImageAlignEnum. CenterCenter

' create data source

dsmessages_dt.C olumns.Add("che ck", GetType(Boolean ))

dsmessages_dt.C olumns.Add("Ima ge", GetType(Image))

dsmessages_dt.C olumns.Add("Lin k", GetType(Hyperli nk))

dsmessages_dt.C olumns("Link"). ReadOnly = True

dsmessages_dt.C olumns.Add("Des cription", GetType(String) )

dsmessages_data .ReadXml("messa ges.xml")

Dim dvmessages As DataView = New
DataView(dsmess ages_data.Table s(dsmessages_da ta.Tables(0).To String))

todo_datagridte mp.DataSource = dvmessages

'dvmessages.Row Filter = "msg_read <> true and msgflag_updated <>
true"

Dim obj As Object = New Object(3) {}

Dim i As Integer

For i = 0 To 5 - 1

Next

' bind the grid to the data source and turn on owner-drawing

todo_datagrid.D ataSource = dsmessages_dt

todo_datagrid.D rawMode = DrawModeEnum.Ow nerDraw

todo_datagrid.C ols(0).Width = 20

todo_datagrid.C ols(1).Width = 20

todo_datagrid.C ols(1).AllowEdi ting = False

todo_datagrid.C ols(2).AllowEdi ting = False

todo_datagrid.C ols(3).AllowEdi ting = False

For i = 0 To dsmessages_data .Tables(0).Rows .Count - 1

obj(0) = dsmessages_data .Tables(0).Rows (i).Item("msg_r ead")

obj(1) =
ImageList1.Imag es(dsmessages_d ata.Tables(0).R ows(i).Item("ms g_notifycode"))

obj(2) = New
Hyperlink(dsmes sages_data.Tabl es(0).Rows(i).I tem("msg_title" ),
dsmessages_data .Tables(0).Rows (i).Item("msg_l ink"))

obj(3) = dsmessages_data .Tables(0).Rows (i).Item("msg_m essage")

If dsmessages_data .Tables(0).Rows (i).Item("msg_r ead") = True
Then

dsmessages_dt.R ows.Add(obj)

End If

Next

Display_todo.Se lectedIndex = 0

Dim dvmessages2 As DataView = dsmessages_dt.D efaultView

End Sub

Sub savechanges()

dsmessages_data .WriteXml("mess ages.xml")
End Sub

Private Sub CheckBox2_Check edChanged(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles CheckBox2.Check edChanged

Dim obj As Object = New Object(3) {}

Dim i As Integer

For i = 0 To dsmessages_data .Tables(0).Rows .Count - 1

todo_datagridte mp.Item(i, 1) = "True"

todo_datagrid.I tem(i, 0) = todo_datagridte mp.Item(i, 1)

Next

Call savechanges()

End Sub

Nov 21 '05 #4

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

Similar topics

0
3135
by: Dave Elliott | last post by:
After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is after the newly added row without getting bizarre results. I have added the full code for the test below. Create a project drop in the code and run. Any help would be appreciated. Cheers,
2
8482
by: Ricardo Luceac | last post by:
HI all.. I have a huge table that I want to display in a datagrid, the problem is that if I make a dataset, the entire table must go to the dataset to the data begin to display, and it takes much time... I need to start show data after a row pushed to the dataset, so I think of using the datareader to populate a datatable and bind the datatable to the datagrid.
12
2904
by: Alphonse Giambrone | last post by:
Is there a simple way to convert the contents of a datatable to an HTML table. I have a dataset containing multiple datatables that I need to be able to insert all the data into an html email. I could loop through the rows of each datatable, but thought there might be a simpler method. TIA --
4
3359
by: bijoy | last post by:
My page has a Listbox called Rooms, a text field called chairPerson and a button called Add. When Add is clicked, the script needs to display the selected info in a datagrid. For example, if the user selects Rooms 1,5 and 7, and enters Bijoy for chairperson and clicks Add, a datagrid on the page should display the following:
3
3196
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something missing from the code? Thanks - Jon Private Sub MakeParentTable() ' Create a new DataTable. Dim myDataTable As Datatable = New Datatable("ParentTable")
0
2599
by: Bob Davies | last post by:
Hi I have a webservice that retrieves data from a database, this is then returned to the calling client application built in windows forms within a dataset, however upon attempting to create tablestyles to format any of the columns within the datagrid, the exception "Can-not parent objects created on one thread to objects created on another" or words to that effect. I'm not too sure if what I said make sense, but i will add details to...
3
8412
by: neeraj | last post by:
Hi Every body I m not able to get dataset or datatable from datagrid. Now I m trying this code but this is always returns nothing. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim tbl As New DataTable Dim ds As New DataSet
3
1977
by: Tom | last post by:
I have a dataTable being returned from my datalayet, I need to convert it to a dataSet so I can do some data manipulation to it prior to populating my datagrid. How can I convert the datatable to a dataset?
9
4031
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New DataTable("SliceInfo") Dim tblSliceRatings As New DataTable("SliceRatings") '.... All the adding datacolumns, datarows, etc. goes here.. DatasetInit.Tables.Add(tblSliceInfo)
0
9797
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
10509
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
10547
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
10219
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
9331
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5793
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4427
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
3977
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3081
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.