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

DataGridView Edit row marker

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


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

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

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