Click here to Skip to main content
15,899,679 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: printing xml in ie Pin
Dave Kreskowiak25-Feb-09 1:51
mveDave Kreskowiak25-Feb-09 1:51 
Questionconvert code into vb.net Pin
sajjadlashari24-Feb-09 1:42
sajjadlashari24-Feb-09 1:42 
AnswerRe: convert code into vb.net Pin
Dave Kreskowiak24-Feb-09 1:57
mveDave Kreskowiak24-Feb-09 1:57 
AnswerRe: convert code into vb.net Pin
Samir Ibrahim24-Feb-09 4:13
Samir Ibrahim24-Feb-09 4:13 
QuestionBeginner for creating Crystal Report with VB.NET2008 WinForm Pin
drexler_kk24-Feb-09 0:40
drexler_kk24-Feb-09 0:40 
AnswerRe: Beginner for creating Crystal Report with VB.NET2008 WinForm Pin
ABitSmart24-Feb-09 17:14
ABitSmart24-Feb-09 17:14 
QuestionRe: Beginner for creating Crystal Report with VB.NET2008 WinForm Pin
drexler_kk25-Feb-09 16:16
drexler_kk25-Feb-09 16:16 
QuestionDatagridview Cellformatting Pin
Chrispie12323-Feb-09 23:48
Chrispie12323-Feb-09 23:48 
Hi
I need help regarding the cell formatting event for the datagridview control in windows forms. I looked on the web and I cannot seem to find a perfect solution for this.
I am using VS 2008 and code in VB.NET.
I have a datagridview with many fields amongst which I have an Effective from date.
If the effective from date is smaller than today’s date certain fields should be disabled and made a funny color.


Private Sub DGV1_CellFormatting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DGV1.CellFormatting
Try
	If e.RowIndex >= -1 And e.RowIndex <= DGV1.RowCount Then 'Basic index validation
		If Not ((DGV1 Is Nothing) OrElse (DGV1.Rows(e.RowIndex) Is Nothing) OrElse (DGV1.Rows(e.RowIndex).DataBoundItem Is Nothing)) Then


			Dim dgvRowState As DataRowState = DirectCast(DGV1.Rows(e.RowIndex).DataBoundItem, DataRowView).Row.RowState
			
			'The idea here is to check that it is only for Non Added/Detatched rows where the Effective From Date is smaller than today
			If Not (dgvRowState = DataRowState.Added OrElse dgvRowState = DataRowState.Detached) _
			   AndAlso e.ColumnIndex = EffectFromDataGridViewTextBoxColumn.Index AndAlso CDate(e.Value).Date < Date.Now.Date Then
				e.CellStyle.BackColor = My.Settings.ReadOnlyColor
				DGV1.Rows(e.RowIndex).Cells(e.ColumnIndex).ReadOnly = True
				DGV1.Rows(e.RowIndex).Cells(Field1.Index).ReadOnly = True
				DGV1.Rows(e.RowIndex).Cells(Field2.Index).ReadOnly = True				

				DGV1.Rows(e.RowIndex).Cells(Field1.Index).Style.BackColor = My.Settings.ReadOnlyColor                            
				DGV1.Rows(e.RowIndex).Cells(Field2.Index).Style.BackColor = My.Settings.ReadOnlyColor
				DGV1.Rows(e.RowIndex).Cells(e.ColumnIndex).Style.BackColor = My.Settings.ReadOnlyColor
				
			End If
		End If
	End If
Catch ex As IndexOutOfRangeException
	Exit Sub 'Exception added to aviod the following behaviour... When the user adds a new line enters a value and use the mouse to
	' navigate to another line, the current new row will be cleared and the cellEndEdit event will be fired. inwhich case the DGV contains
	' a blank row that is not dirty. The row  "DGV1.Rows(RowIndex).DataBoundItem" part gives an exception for this row
End Try


This works well…
But the problem I am having is when I go to a row where the Effective from date is greater than today and where cells is not read only and change the effective from date to the past that row also changes.

I don’t want this to happen until the user presses on the save button. I debugged the code and found that the dgvRowState variable = UNCHANGHED. Thus it never reaches ADDED or DETATCHED.

Is the way I determine the rowstate wrong? Or is there another way to do this?

Thanks,
Chris
QuestionHow to check whether a particuar file exists on FTP server through VB.Net Pin
nav_duggal23-Feb-09 23:39
nav_duggal23-Feb-09 23:39 
AnswerRe: How to check whether a particuar file exists on FTP server through VB.Net Pin
leckey24-Feb-09 4:58
leckey24-Feb-09 4:58 
QuestionSQL SERVER Login error...! Pin
Jamal Abdul Nasir23-Feb-09 23:02
Jamal Abdul Nasir23-Feb-09 23:02 
AnswerRe: SQL SERVER Login error...! Pin
Dave Kreskowiak24-Feb-09 1:55
mveDave Kreskowiak24-Feb-09 1:55 
AnswerRe: SQL SERVER Login error...! Pin
Eddy Vluggen24-Feb-09 2:14
professionalEddy Vluggen24-Feb-09 2:14 
AnswerRe: SQL SERVER Login error...! Pin
Dave Kreskowiak24-Feb-09 3:29
mveDave Kreskowiak24-Feb-09 3:29 
QuestionHow to FTP a file not existing on server through vb.net Pin
nav_duggal23-Feb-09 20:03
nav_duggal23-Feb-09 20:03 
AnswerRe: How to FTP a file not existing on server through vb.net Pin
JR21223-Feb-09 20:52
JR21223-Feb-09 20:52 
GeneralRe: How to FTP a file not existing on server through vb.net Pin
nav_duggal23-Feb-09 20:58
nav_duggal23-Feb-09 20:58 
AnswerRe: How to FTP a file not existing on server through vb.net Pin
kadaoui el mehdi23-Feb-09 21:00
kadaoui el mehdi23-Feb-09 21:00 
QuestionPrinting xml Pin
Stephen Lintott23-Feb-09 20:01
Stephen Lintott23-Feb-09 20:01 
Questionhow to bind checkedlistbox with dataset in vb.net (window application) Pin
Jagz W23-Feb-09 19:06
professionalJagz W23-Feb-09 19:06 
AnswerRe: how to bind checkedlistbox with dataset in vb.net (window application) Pin
Dave Kreskowiak24-Feb-09 3:51
mveDave Kreskowiak24-Feb-09 3:51 
QuestionUsing Reflection to on a Subclass as a Property Pin
nickbequick23-Feb-09 11:52
nickbequick23-Feb-09 11:52 
AnswerRe: Using Reflection to on a Subclass as a Property Pin
Dave Kreskowiak24-Feb-09 3:50
mveDave Kreskowiak24-Feb-09 3:50 
GeneralRe: Using Reflection to on a Subclass as a Property Pin
nickbequick24-Feb-09 4:01
nickbequick24-Feb-09 4:01 
GeneralRe: Using Reflection to on a Subclass as a Property Pin
Dave Kreskowiak24-Feb-09 6:17
mveDave Kreskowiak24-Feb-09 6:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.