472,984 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,984 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 2456
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.