473,395 Members | 1,977 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,395 software developers and data experts.

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 7777
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bharathi Kumar | last post by:
Hi, Iam working on a window application using vb.net 2005. There is a control "DataGridView" in vs 2005 instead of data grid control. After binding the datagridview, When we click on any...
0
by: Marino | last post by:
Hi! I am trying to make a simplest possible thing, load a database table in a datagridview, edit one cell and save a change to the database. And i just can't make it happen. I can load the...
0
by: Brahm | last post by:
hi guys, how can I make datagridview edit effective in database ? Daniel
1
by: Gaurangkumar Shah | last post by:
Hi I am working with datagridview. When I am editing the cell I am not able to catch the keyup, Key down events. Can u plz help me to solve the problem.
1
by: kristian | last post by:
Hi all I have a simple form with not much more than a datagridview control, and want to show and edit the contents of a table in my mysql table. So far I have managed to set the db table as a...
2
by: Rick | last post by:
VS 2005/Pro I'm using a DataGridView in a Windows form and allowing the user to sort the columns by clicking on the header column. Is there some method offered by the grid to return back to...
1
by: rgparkins | last post by:
HI I am struggling with this one and its got to be a simple solution. I have 3 columns in a datagridview the 4th being the edit/delete buttons for that row, when I click the edit button I have the...
12
by: cj | last post by:
When viewing a datatable in a datagridview one of the columns in it is a "note" field which can be quite long. I would like to have the note field of the currently selected row of the datagrid...
6
by: Miro | last post by:
Sorry for the cross post. I am stuck. I have a datagridview for poker rounds. Basically there are 3 columns in this datagridview. "Round" "SmallBlind" "BigBlind" I have an issue when I tab...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.