Dear All,
1. Can anybody tell me how can i disable a cell of datagrid in vb.net
2. How can i show current date in datagrid cell
i have used this peace of code on form load event
DataGridView1.CurrentRow.Cells(7).Value = Now
DataGridView1.CurrentRow.Cells(0).ReadOnly = True
but it give me message object reference is not set to an instance of object what should i do to resolve these two issues.
How to disable cells in VB.NET datagrid
Page 1 of 19 Replies - 2157 Views - Last Post: 11 August 2011 - 07:19 AM
Replies To: How to disable cells in VB.NET datagrid
#2
Re: How to disable cells in VB.NET datagrid
Posted 10 August 2011 - 11:37 AM
Would your grid even have rows it in at that point? I mean if there is no "current row" that would be a problem.
This is easily determined by putting a break point on that first line and checking to see if 'current row' exists or not.
This is easily determined by putting a break point on that first line and checking to see if 'current row' exists or not.
#3
Re: How to disable cells in VB.NET datagrid
Posted 10 August 2011 - 12:10 PM
Yes it has current row
#4
Re: How to disable cells in VB.NET datagrid
Posted 10 August 2011 - 12:20 PM
Okay then you attempting to access cells/columns before they are set.
Either you have no rows or cells.
Either you have no rows or cells.
#5
Re: How to disable cells in VB.NET datagrid
Posted 11 August 2011 - 05:55 AM
I didn't understand please any body can help me.
#6
Re: How to disable cells in VB.NET datagrid
Posted 11 August 2011 - 06:25 AM
Hi naveed_786.
i would like to know the result message that will return the following code
cause as modi123_1 said this error occurs if there is no Currentrow.
i would like to know the result message that will return the following code
MsgBox(DataGridView1.CurrentRow.Cells(7).ToString)
cause as modi123_1 said this error occurs if there is no Currentrow.
#7
Re: How to disable cells in VB.NET datagrid
Posted 11 August 2011 - 06:44 AM
I got this message
Datagridview textboxcell{Columnindex = 7, Rowindex = 0}
#8
Re: How to disable cells in VB.NET datagrid
Posted 11 August 2011 - 06:50 AM
Okay let me play my self
#9
Re: How to disable cells in VB.NET datagrid
Posted 11 August 2011 - 07:04 AM
Okay when i write this code on click event of a buton
It works fine but i want to write this code on form load event here it gives me error how to resolve it error is
"bject reference is not set to an instance of object"
DataGridView1.CurrentRow.Cells(7).Value = Now
DataGridView1.CurrentRow.Cells("PR_NO").ReadOnly = True
It works fine but i want to write this code on form load event here it gives me error how to resolve it error is
"bject reference is not set to an instance of object"
#10
Re: How to disable cells in VB.NET datagrid
Posted 11 August 2011 - 07:19 AM
Here is the solution i have done it
Private Sub dataGridView1_CellClick(ByVal sender As Object, _
ByVal e As DataGridViewCellEventArgs) _
Handles DataGridView1.CellClick
DataGridView1.CurrentRow.Cells(0).ReadOnly = True
DataGridView1.CurrentRow.Cells(7).Value = Now
End Sub
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote






|