473,289 Members | 1,840 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,289 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 2484
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.