By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,266 Members | 1,816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,266 IT Pros & Developers. It's quick & easy.

Datatable Dataset Datagrid help

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.