473,378 Members | 1,454 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,378 software developers and data experts.

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.Columns.Add("Image", 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>True</msg_read>
<msg_type>High</msg_type>
<msg_link>www.google.com</msg_link>
<msg_title>Read Message</msg_title>
<msg_message>Customer 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>High</msg_type>
<msg_link>www.solarblu.com</msg_link>
<msg_title>Read Message</msg_title>
<msg_message>Customer 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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles button1.Click

Me.refToB.notifiedoff = True

'Me.Close()

'Me.refTomainform.frm_Closed()

Me.refToB.frm_Closed()

Me.ActiveForm.Close()

End Sub

Private Sub taskbarmessages_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

' create custom style for links

Dim cs As CellStyle = todo_datagrid.Styles.Add("NewLink")

cs.Font = New Font(todo_datagrid.Font, FontStyle.Underline)

cs.ForeColor = Color.Blue

cs = todo_datagrid.Styles.Add("OldLink")

cs.Font = New Font(todo_datagrid.Font, FontStyle.Underline)

cs.ForeColor = Color.Purple

cs = todo_datagrid.Styles.Add("bool")

cs.DataType = Type.GetType("System.Boolean")

cs.ImageAlign = ImageAlignEnum.CenterCenter

' create data source

dsmessages_dt.Columns.Add("check", GetType(Boolean))

dsmessages_dt.Columns.Add("Image", GetType(Image))

dsmessages_dt.Columns.Add("Link", GetType(Hyperlink))

dsmessages_dt.Columns("Link").ReadOnly = True

dsmessages_dt.Columns.Add("Description", GetType(String))

dsmessages_data.ReadXml("messages.xml")

Dim dvmessages As DataView = New
DataView(dsmessages_data.Tables(dsmessages_data.Ta bles(0).ToString))

todo_datagridtemp.DataSource = dvmessages

'dvmessages.RowFilter = "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.DataSource = dsmessages_dt

todo_datagrid.DrawMode = DrawModeEnum.OwnerDraw

todo_datagrid.Cols(0).Width = 20

todo_datagrid.Cols(1).Width = 20

todo_datagrid.Cols(1).AllowEditing = False

todo_datagrid.Cols(2).AllowEditing = False

todo_datagrid.Cols(3).AllowEditing = False

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

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

obj(1) =
ImageList1.Images(dsmessages_data.Tables(0).Rows(i ).Item("msg_notifycode"))

obj(2) = New
Hyperlink(dsmessages_data.Tables(0).Rows(i).Item(" msg_title"),
dsmessages_data.Tables(0).Rows(i).Item("msg_link") )

obj(3) = dsmessages_data.Tables(0).Rows(i).Item("msg_messag e")

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

dsmessages_dt.Rows.Add(obj)

End If

Next

Display_todo.SelectedIndex = 0

Dim dvmessages2 As DataView = dsmessages_dt.DefaultView

End Sub

Sub savechanges()

dsmessages_data.WriteXml("messages.xml")
End Sub

Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged

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

Dim i As Integer

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

todo_datagridtemp.Item(i, 1) = "True"

todo_datagrid.Item(i, 0) = todo_datagridtemp.Item(i, 1)

Next

Call savechanges()

End Sub
Nov 21 '05 #1
3 2490
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**@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.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.Columns.Add("Image", 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>True</msg_read>
<msg_type>High</msg_type>
<msg_link>www.google.com</msg_link>
<msg_title>Read Message</msg_title>
<msg_message>Customer 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>High</msg_type>
<msg_link>www.solarblu.com</msg_link>
<msg_title>Read Message</msg_title>
<msg_message>Customer 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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles button1.Click

Me.refToB.notifiedoff = True

'Me.Close()

'Me.refTomainform.frm_Closed()

Me.refToB.frm_Closed()

Me.ActiveForm.Close()

End Sub

Private Sub taskbarmessages_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

' create custom style for links

Dim cs As CellStyle = todo_datagrid.Styles.Add("NewLink")

cs.Font = New Font(todo_datagrid.Font, FontStyle.Underline)

cs.ForeColor = Color.Blue

cs = todo_datagrid.Styles.Add("OldLink")

cs.Font = New Font(todo_datagrid.Font, FontStyle.Underline)

cs.ForeColor = Color.Purple

cs = todo_datagrid.Styles.Add("bool")

cs.DataType = Type.GetType("System.Boolean")

cs.ImageAlign = ImageAlignEnum.CenterCenter

' create data source

dsmessages_dt.Columns.Add("check", GetType(Boolean))

dsmessages_dt.Columns.Add("Image", GetType(Image))

dsmessages_dt.Columns.Add("Link", GetType(Hyperlink))

dsmessages_dt.Columns("Link").ReadOnly = True

dsmessages_dt.Columns.Add("Description", GetType(String))

dsmessages_data.ReadXml("messages.xml")

Dim dvmessages As DataView = New
DataView(dsmessages_data.Tables(dsmessages_data.Ta bles(0).ToString))

todo_datagridtemp.DataSource = dvmessages

'dvmessages.RowFilter = "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.DataSource = dsmessages_dt

todo_datagrid.DrawMode = DrawModeEnum.OwnerDraw

todo_datagrid.Cols(0).Width = 20

todo_datagrid.Cols(1).Width = 20

todo_datagrid.Cols(1).AllowEditing = False

todo_datagrid.Cols(2).AllowEditing = False

todo_datagrid.Cols(3).AllowEditing = False

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

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

obj(1) =
ImageList1.Images(dsmessages_data.Tables(0).Rows(i ).Item("msg_notifycode"))

obj(2) = New
Hyperlink(dsmessages_data.Tables(0).Rows(i).Item(" msg_title"),
dsmessages_data.Tables(0).Rows(i).Item("msg_link") )

obj(3) = dsmessages_data.Tables(0).Rows(i).Item("msg_messag e")

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

dsmessages_dt.Rows.Add(obj)

End If

Next

Display_todo.SelectedIndex = 0

Dim dvmessages2 As DataView = dsmessages_dt.DefaultView

End Sub

Sub savechanges()

dsmessages_data.WriteXml("messages.xml")
End Sub

Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged

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

Dim i As Integer

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

todo_datagridtemp.Item(i, 1) = "True"

todo_datagrid.Item(i, 0) = todo_datagridtemp.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**@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.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.Columns.Add("Image", 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>True</msg_read>
<msg_type>High</msg_type>
<msg_link>www.google.com</msg_link>
<msg_title>Read Message</msg_title>
<msg_message>Customer 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>High</msg_type>
<msg_link>www.solarblu.com</msg_link>
<msg_title>Read Message</msg_title>
<msg_message>Customer 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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles button1.Click

Me.refToB.notifiedoff = True

'Me.Close()

'Me.refTomainform.frm_Closed()

Me.refToB.frm_Closed()

Me.ActiveForm.Close()

End Sub

Private Sub taskbarmessages_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

' create custom style for links

Dim cs As CellStyle = todo_datagrid.Styles.Add("NewLink")

cs.Font = New Font(todo_datagrid.Font, FontStyle.Underline)

cs.ForeColor = Color.Blue

cs = todo_datagrid.Styles.Add("OldLink")

cs.Font = New Font(todo_datagrid.Font, FontStyle.Underline)

cs.ForeColor = Color.Purple

cs = todo_datagrid.Styles.Add("bool")

cs.DataType = Type.GetType("System.Boolean")

cs.ImageAlign = ImageAlignEnum.CenterCenter

' create data source

dsmessages_dt.Columns.Add("check", GetType(Boolean))

dsmessages_dt.Columns.Add("Image", GetType(Image))

dsmessages_dt.Columns.Add("Link", GetType(Hyperlink))

dsmessages_dt.Columns("Link").ReadOnly = True

dsmessages_dt.Columns.Add("Description", GetType(String))

dsmessages_data.ReadXml("messages.xml")

Dim dvmessages As DataView = New
DataView(dsmessages_data.Tables(dsmessages_data.Ta bles(0).ToString))

todo_datagridtemp.DataSource = dvmessages

'dvmessages.RowFilter = "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.DataSource = dsmessages_dt

todo_datagrid.DrawMode = DrawModeEnum.OwnerDraw

todo_datagrid.Cols(0).Width = 20

todo_datagrid.Cols(1).Width = 20

todo_datagrid.Cols(1).AllowEditing = False

todo_datagrid.Cols(2).AllowEditing = False

todo_datagrid.Cols(3).AllowEditing = False

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

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

obj(1) =
ImageList1.Images(dsmessages_data.Tables(0).Rows(i ).Item("msg_notifycode"))

obj(2) = New
Hyperlink(dsmessages_data.Tables(0).Rows(i).Item(" msg_title"),
dsmessages_data.Tables(0).Rows(i).Item("msg_link") )

obj(3) = dsmessages_data.Tables(0).Rows(i).Item("msg_messag e")

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

dsmessages_dt.Rows.Add(obj)

End If

Next

Display_todo.SelectedIndex = 0

Dim dvmessages2 As DataView = dsmessages_dt.DefaultView

End Sub

Sub savechanges()

dsmessages_data.WriteXml("messages.xml")
End Sub

Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged

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

Dim i As Integer

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

todo_datagridtemp.Item(i, 1) = "True"

todo_datagrid.Item(i, 0) = todo_datagridtemp.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
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...
2
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...
12
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...
4
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...
3
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...
0
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...
3
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...
3
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...
9
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.