469,909 Members | 1,742 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,909 developers. It's quick & easy.

DataGridView Edit row marker

Hello All

In my windows application I am using DataGridView as my grid control. I
populated let's say 10 rows of data and modified 3 random rows. I need to
put some sort of Edit Marker in the row header. This can be an image. Please
any one share a code for this implementation.

If i were to save this records, how can I trap those 3 modified rows without
going throgh the whole row set?

Thanks in Advance
Prash
Nov 6 '06 #1
3 7597
Prashwee,

I achieve something similiar when a check box value has changed, add a
DataGridViewImageCell 1st and an ImageList with your Status images in it,
and then trap the CellFormatting event like below

<code>
Private Sub DataGridView1_CellFormatting(ByVal sender As Object, ByVal e As
DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting
If e.ColumnIndex = 0 Then setDGVImageStatus(sender, e)
If e.ColumnIndex = 3 Then setDGVSignificant(sender, e)
End Sub
</code>

And add the following Sub for actually setting the Image cell's value -
Don't forget validation :-)
I was trapping when value of my ComboBox

''' <summary>
''' Sets the image column of the datagridview dependant on the value
of the ysnResolved column
''' </summary>
''' <param name="sender">The DataGridView who's column needs
altering</param>
''' <param name="e">DataGridViewCellFormattingEventArgs</param>
''' <remarks>Sender as object so that this block can be reused for
both grids</remarks>
Private Sub setDGVImageStatus(ByVal sender As Object, ByVal e As
DataGridViewCellFormattingEventArgs)
Dim colName As String = DirectCast(sender,
DataGridView).Columns(e.ColumnIndex).Name.ToString
'getResolvedDGVColName(sender) just returns the column name of my
DataGridViewCheckBoxCell

If DirectCast(sender,
DataGridView).Rows(e.RowIndex).Cells(getResolvedDG VColName(sender)).Value.Equals(False)
Then
e.Value = iml.Images(1)
Else
e.Value = iml.Images(0)
End If

End Sub

Hope that Helps you out - if not let me know
Brendon

"Prashwee" <pr******************@ifs.lkwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hello All

In my windows application I am using DataGridView as my grid control. I
populated let's say 10 rows of data and modified 3 random rows. I need to
put some sort of Edit Marker in the row header. This can be an image.
Please any one share a code for this implementation.

If i were to save this records, how can I trap those 3 modified rows
without going throgh the whole row set?

Thanks in Advance
Prash
Nov 6 '06 #2
Hello Brendon

Where do you insert your image in the grid?
Is it in the row header colunm or just another grid cell?
/Prash

"Brendon Bezuidenhout" <ab****@bezfamily.netwrote in message
news:Og**************@TK2MSFTNGP02.phx.gbl...
Prashwee,

I achieve something similiar when a check box value has changed, add a
DataGridViewImageCell 1st and an ImageList with your Status images in it,
and then trap the CellFormatting event like below

<code>
Private Sub DataGridView1_CellFormatting(ByVal sender As Object, ByVal e
As DataGridViewCellFormattingEventArgs) Handles
DataGridView1.CellFormatting
If e.ColumnIndex = 0 Then setDGVImageStatus(sender, e)
If e.ColumnIndex = 3 Then setDGVSignificant(sender, e)
End Sub
</code>

And add the following Sub for actually setting the Image cell's value -
Don't forget validation :-)
I was trapping when value of my ComboBox

''' <summary>
''' Sets the image column of the datagridview dependant on the
value of the ysnResolved column
''' </summary>
''' <param name="sender">The DataGridView who's column needs
altering</param>
''' <param name="e">DataGridViewCellFormattingEventArgs</param>
''' <remarks>Sender as object so that this block can be reused for
both grids</remarks>
Private Sub setDGVImageStatus(ByVal sender As Object, ByVal e As
DataGridViewCellFormattingEventArgs)
Dim colName As String = DirectCast(sender,
DataGridView).Columns(e.ColumnIndex).Name.ToString
'getResolvedDGVColName(sender) just returns the column name of my
DataGridViewCheckBoxCell

If DirectCast(sender,
DataGridView).Rows(e.RowIndex).Cells(getResolvedDG VColName(sender)).Value.Equals(False)
Then
e.Value = iml.Images(1)
Else
e.Value = iml.Images(0)
End If

End Sub

Hope that Helps you out - if not let me know
Brendon

"Prashwee" <pr******************@ifs.lkwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>Hello All

In my windows application I am using DataGridView as my grid control. I
populated let's say 10 rows of data and modified 3 random rows. I need to
put some sort of Edit Marker in the row header. This can be an image.
Please any one share a code for this implementation.

If i were to save this records, how can I trap those 3 modified rows
without going throgh the whole row set?

Thanks in Advance
Prash

Nov 7 '06 #3
Pashwee,

Add a DataGridViewImageColumn to the DataGridView and an ImageList to the
form - Failing that search for DataGridViewImageColum and
DataGridViewImageCell on Google

HTH
Brendon

"Prashwee" <pr******************@ifs.lkwrote in message
news:eu**************@TK2MSFTNGP02.phx.gbl...
Hello Brendon

Where do you insert your image in the grid?
Is it in the row header colunm or just another grid cell?
/Prash

"Brendon Bezuidenhout" <ab****@bezfamily.netwrote in message
news:Og**************@TK2MSFTNGP02.phx.gbl...
>Prashwee,

I achieve something similiar when a check box value has changed, add a
DataGridViewImageCell 1st and an ImageList with your Status images in it,
and then trap the CellFormatting event like below

<code>
Private Sub DataGridView1_CellFormatting(ByVal sender As Object, ByVal e
As DataGridViewCellFormattingEventArgs) Handles
DataGridView1.CellFormatting
If e.ColumnIndex = 0 Then setDGVImageStatus(sender, e)
If e.ColumnIndex = 3 Then setDGVSignificant(sender, e)
End Sub
</code>

And add the following Sub for actually setting the Image cell's value -
Don't forget validation :-)
I was trapping when value of my ComboBox

''' <summary>
''' Sets the image column of the datagridview dependant on the
value of the ysnResolved column
''' </summary>
''' <param name="sender">The DataGridView who's column needs
altering</param>
''' <param name="e">DataGridViewCellFormattingEventArgs</param>
''' <remarks>Sender as object so that this block can be reused for
both grids</remarks>
Private Sub setDGVImageStatus(ByVal sender As Object, ByVal e As
DataGridViewCellFormattingEventArgs)
Dim colName As String = DirectCast(sender,
DataGridView).Columns(e.ColumnIndex).Name.ToStrin g
'getResolvedDGVColName(sender) just returns the column name of my
DataGridViewCheckBoxCell

If DirectCast(sender,
DataGridView).Rows(e.RowIndex).Cells(getResolvedD GVColName(sender)).Value.Equals(False)
Then
e.Value = iml.Images(1)
Else
e.Value = iml.Images(0)
End If

End Sub

Hope that Helps you out - if not let me know
Brendon

"Prashwee" <pr******************@ifs.lkwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>Hello All

In my windows application I am using DataGridView as my grid control. I
populated let's say 10 rows of data and modified 3 random rows. I need
to put some sort of Edit Marker in the row header. This can be an image.
Please any one share a code for this implementation.

If i were to save this records, how can I trap those 3 modified rows
without going throgh the whole row set?

Thanks in Advance
Prash

Nov 7 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Bharathi Kumar | last post: by
reply views Thread by Marino | last post: by
1 post views Thread by Gaurangkumar Shah | last post: by
1 post views Thread by rgparkins | last post: by
6 posts views Thread by Miro | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.