Atagridview.readonly = True Throws Nullreferenceexception?

Mar 30, 2009

I have a project that I am working on which requires my datagridview to have certain columns set as readonly according to the user authentication results. But, almost every time I set readonly = true I get a nullreference exception.I have added ALL the datagridview events trying to see where I can handle this problem. The only event it calls into after I say readonly = "true" is my cell validation event. And that event always passes fine. It is after I hit f11 to continue past the "End Sub" of my validate event that I return to the calling code and all of the sudden have an exception too.

I've looked around and can't figure out how to debug this one so I am asking for help here. I have seen other bugs about scrolling content in columns and turning off scrollbars to fix random datagridview bugs but I dont know about this one. I can't find the same problem anywhere else yet.

-my admin timer elapses and I call a timeout routine which sets the grids back to readonly = true. One of my grids (one bound by datatable/bindingsource) almost always throws a nullreference when I set the readonly = true.

-when authenticating my user if their credentials pass I want to set the whole grid to readonly = false, and then individually set two columns to readonly = true so they cannot be modified while the rest of the grid is editable. I throw my nullreference here after my first individual column call to readonly = true.

I'm using multiple grids on my project, but the timeout nullreference exception seems to be tied directly to only one of my grids. In particular, this problem grid has the least complicated queries and barely any cell validation. I dont understand how it could be the cause of so much frustration. However, it seems that when changing readonly property on individual columns that both my main grids for my project will exhibit the same behaviors with the nullreference exception.

It's important to note that usually I can just drag the debugger back into the failure statement and it will actually succeed.By figuring this out I was able to set a flag if I wasn't able to change the status of the grid and recall it. Usually that fixes most things, but when it comes to doing the individual columns I cannot code my project to try/catch/recurse for each individual column.

I've got source and a test DB available if needed.I am not sure what is relevant out of my project to post? But I can offer some compensation via Paypal if someone on this board actually helps me fix my problem in a way that I can understand and troubleshoot for future projects. This is the last bit of functionality for my requirements and I have about 48 hours to get it bug free and working as designed or I will have to revert to some older spaghetti code and do a lot of this over.

View 9 Replies


ADVERTISEMENT

Xml - Getting InnerText From XmlDocument Throws NullReferenceException

Oct 28, 2011

Whenever I try and get the InnerText of an element using an XmlDocument, it throws a NullReferenceException. Here is the code below:

Dim SetDoc As New XmlDocument
Dim xmlString As String = "<upload><links><bananas>apple</bananas><original>thirteen</original></links></upload>"

[Code].....

The same happens when I load exactly the same XML from file.

View 1 Replies

Web Service Stumper - Throws A NullReferenceException Error When Trying To Access The Data

Feb 7, 2011

I have created a very basic web service in vb.net using vs 2008. When I run the service within visual studio debugger, the service runs fine and gives me the expected results. When I deploy the service to the server and invoke it from a client, it always throws a NullReferenceException error when trying to access the data. More specifically when I call the DbConnection open() method within a dbhelper executeScalar method.

I'm using a custom dbhelper class I found on the web here: [URL] The only thing I've changed is the _factory at the top points to Providers.Odbc (since I'm using a ODBC connection). Like I said previously, the service (and the dbhelper class) work as expected within VS- it's only once I deploy it that it seems to bomb out. I've even tried hard coding the connection string in case it was having problems getting that but no difference there.

View 2 Replies

If - Else Condition First Code Won't Execute - Add Some Codes Besides Readonly Being Set To True And False

Feb 10, 2011

I have a form called LogIn.vb which has no errors. After log-in, it opens the MainForm.vb which IsMDIContainer property is set to true. From the MainMenu, it opens a child form called Assure_Benefits.vb So far no problem up to this point. When Assure_Benefits.vb loads, it displays 2 DataGridViews with datasourses from my 2 tables in my database.

There is still no problem with the loading. Now, to show the difference between different user types, I only allow the admin to edit the DataGrid. SO I set the readonly property to true when UserType = "user".

I have no problem doing that. My problem is I want to add some codes besides the readonly being set to true and false but other codes are not executed and the program does not display any errors at all. i tried to add messageboxes on the if and else conditions to try if added codes will work but even the messagebox does not appear though the codes next to it are properly executed.

When my Assure_Benefits.vb loads I call for the subroutine below.

Private Sub SetControlProperties()
If LogIn.UserType = "admin" Then
MessageBox.Show("Yes") 'This line is not executed

[CODE]...

I can't seem to understand why the first code is not executed when the next codes works fine.

View 5 Replies

VS 2008 Make The Same Effect That Textbox1.readonly = True In An Combobox

Apr 30, 2010

the code bellow try to make the same effect that textbox1.readonly = True in an combobox...the code to do this are in a form class and because i never had work with class i don't knoe the way to call this class..

Option Strict Off
Public Class ComboBoxReadOnly
Inherits System.Windows.Forms.ComboBox

[Code].....

View 2 Replies

Fill_Text Code Throws An Error : System.NullReferenceException:Object Reference Not Set To An Instance Of An Object

Apr 18, 2010

I got the following code from the demo code samples and just changed the textbox names. But it throws an error:

Private Sub Fill_TextBox()
Dim Num As Integer
Dim DSet As DataSet

[code]....

The error is:

System.NullReferenceException:Object reference not set to an instance of an object.

View 1 Replies

.net - Setting ReadOnly Property In PropertyGrid Sets All Properties Readonly?

Jun 12, 2012

I am using a PropertyGrid control to edit my class properties and I am trying to set certain properties read-only depending on other property settings.This is the code of my class:

Imports System.ComponentModel
Imports System.Reflection
Public Class PropertyClass[code].....

This is the code I am using to edit the values:

Dim c As New PropertyClass
PropertyGrid1.SelectedObject = c


The problem is that when I set SomeProperty to True, nothing happens and when I then set it to False again it sets all properties Read-Only.

View 1 Replies

Getting Error " Only True Type Fonts Are Supported. This Is A Not True Type Font"

Oct 2, 2010

i am using VS 2008 and just started to work with XAML and WPF. while opening in page(.xaml) in design mode i'm getting the error like this "Only TrueType fonts are supported and this is not a TrueType font".

View 7 Replies

Inter-Program Variables - If A Variable In Form1 Is "True" Than, How Can Make A Variable In Form2 Turns To "True" Too?

Feb 11, 2012

I know that

Public Incognito As Boolean

is a variable called "Incognito" that is class-wide that is a boolean.My question is that is there a form-wide variable form that can like communicate with different forms. So if a variable in form1 is "True" than, how can you make a variable in form2 turns to "True" too?

View 1 Replies

RowValidating Throws Exception?

May 6, 2012

I use DataGridView in my project. Everything worked fine until I added some code in the RowValidating event. During the form_load event exception is thrown on the statement that set the datasource of the DataGridView.The project uses bindingsource for the datasource of the DataGridView. My validating code is shown below:

Dim currentRow As DataGridViewRow = Me.dgExpenditure.Rows(e.RowIndex)
Dim incexpCell As DataGridViewCell = currentRow.Cells(0)
If Not Me.closingBoolean Then

[code]....

View 3 Replies

.net - Collection Initialisation Using Iif() Throws ArgumentNullException?

Jan 31, 2012

why this gives an error at run-time:

Dim mightBeNothing As List(Of String) = Nothing
Dim a As List(Of String) = IIf(mightBeNothing Is Nothing, New List(Of String)(), New List(Of String)(mightBeNothing))

I am getting ArgumentNullException on the second line. If I replace the last part with:

Dim a As List(Of String) = IIf(mightBeNothing Is Nothing, New List(Of String)(), New List(Of String)())

It works - but the constructor New List(Of String)(mightBeNothing) will never be called if mightBeNothing is nothing, so what is the issue?

View 3 Replies

Add DB Query To DGV Throws Exception When Adding Row

Apr 24, 2011

I debated whether or not to ask in the database section, but decided this was probably more of a VB question, than DB.I'm performing a query on my database and add its value to a DGV. At the moment, I'm just running tests to make sure the base example works so I can expand on it for more advanced tests.[code]It doesn't matter how I add the row, just adding it causes the error. And yes, the AllowUsersToAddRows property of the DGV is set to True, which wouldn't cause this problem anyway, but I decided to be extra careful.

View 1 Replies

Checking For DBNull Throws A StrongTypingException?

Jan 14, 2011

I am using a dataset to pull data from a DB. One of the fields in a row is NULL. I know this. However, the following vb.net code throws a StrongTypingException (in the autogenerated get_SomeField() method in the dataset designer):

If Not IsDBNull(aRow.SomeField) Then
'do something
End If

According to documentation and this question it should be fine.

View 5 Replies

DataReader Instance Throws An Exception

Nov 14, 2009

i want to run a query and use the result for something else in my vb.net code. I have, opened the connection, passed the query and the connection object to the SqlCommand object and read it with the datareader object. The DataReader's HasRows property's value evaluates to true but i get an InvalidOperationException when i want to access the results of the query with the DataReader.[code]

View 1 Replies

GlutInit() Throws An Error - Cannot Find DLL?

Jan 17, 2011

I'm currently building an application in C#, using a basic design I came up with in VB.net for applications involving openGL. Using the Tao framework in VB, I have the following method:

Private Sub checkForGlutInit()
If glut_initialized = False Then
Glut.glutInit()

[code].....

View 1 Replies

Items.AddRange Throws Exception If Used More Than Once?

Nov 15, 2011

I'm having an issue with updating a couple list boxes in the form load procedure. I have an array created from a MySQL database, and when I try to add that array to more than one ListBox, I get: A first chance exception of type 'System.ArgumentNullException' occurred in System.Windows.Forms.dll

[Code]...

View 1 Replies

Program That Throws Out A String Of Six Numbers From 1 To 37?

Feb 12, 2012

I have a program that throws out a string of six numbers from 1 to 37, what I need to do is check the the string for for a format you could say.I need to make sure the set of six numbers doesn't contain 4 or more numbers of the same numbers from the same set of ten(s).

Like this:I can't have: 1-3-6-7-8-12 Or 12-14-16-18-20-21 Or 21-23-26-28-30-31 Or 30-32-34-36-20-22

I can have : 1-3-6-12-17-23
////////////: 12-14-16-20-21-22
////////////: 20-1-13-23-26-30
////////////: 1-37-22-33-30-9

[Code]...

View 5 Replies

Radio Button Throws Exception

Oct 1, 2010

I'm getting a "IndexOutOfRangeExeption was unhandled" in my project

Private Sub LookUpButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LookUpButton.Click
'Look up the information on the state.

[Code].....

I'm about ready to give up and go another route. I just thought I'd ask here.

View 3 Replies

Sql Server - Update DateTime Into Sql Db Throws?

May 31, 2011

I am trying to update a DateTime object into a datetime field of a sql (SQL Server 2000) database.I have the following function

Public Sub Update(ByVal lastlogin as DateTime)
Using slqupdate as SqlCommand = _connection.CreateCommand()
sqlupdate.CommandType = CommandType.Text

[code].....

View 2 Replies

StringCollection Setting Throws Exception?

Dec 10, 2011

For Each ScreenName As String In da.settings_LinkedScreenNames

View 5 Replies

WebControls.TableRow Throws Exception On Add()

Aug 19, 2010

I have the following method to strip hidden and user-specified columns from a gridviewrow and return a tablerow. [Code] However, when I run this code and hit the Add method for the TableRow, I get an InvalidOperationException stating the Collection was modified; enumeration operation may not execute. I've gotten this exception before, but usually it's because I'm attempting to modify a table that is databound.

View 3 Replies

WPF .Net OpenFileDialog.ShowDialog() Throws An Exception?

Jun 21, 2011

I am trying to show a dialog from one of my WPF view model commands however when i call ShowDialog() it throws a System.ArgumentException?

Here is my code:

Public ReadOnly Property OpenParser As ICommand
Get
Return New RelayCommand(Sub(param As Object) OpenParserExecute(DirectCast(param, Frame)))
End Get

[code]....

View 1 Replies

.net - App Works In IDE But Throws An Error When Compiled And Run On Another Machine?

Nov 15, 2009

I have created an application using VB.NET in VS2008. When I run the app in the IDE on my development machine it works fine. It also works fine when I build it and run it as an exe on any machine that also has Visual Studio installed (at least 2005 and 2008 anyway) However, when I try to run the compiled executable on any machine without Visual Studio it throws up an error "[program name] has encountered a problem and will close..."

View 5 Replies

Call A Function Everytime It Throws An Error?

Apr 2, 2011

Is there a way to call a function everytime it throws an error? I could use try catch, but I need to do it with unexpected errors.

View 8 Replies

Code Change Throws Object Error

Sep 16, 2010

I have a piece of code that I believe is the culprit in a "Object reference not set to an instance of an object" error being thrown.[code]

View 4 Replies

Convert.ToInt16(arr(10).ToString()) Throws FormatException If Value For Arr(10) = '0B'

Aug 19, 2010

I use the expression below to evaluate for a certain value, '91'. If however, the value at that array position is '0B' a System.FormatException is thrown. How do I alter the evaluation so this exception won't be thrown?

View 12 Replies

DataAdapter.Update Throws DBConcurrency Exception

Mar 22, 2012

I was working with a class used to update database.All things were working for 3 years perfactly.Now it started throwing exception for two records only.When i edit these two records and try to save back to db it throws exception.Else it works fine.

View 3 Replies

DB/Reporting :: DataGridView Throws An Error When Remove A Row

Mar 16, 2012

Yes its me again with yet another problem Ok so I've now gotten round to trying to display some data from my database and displaying it in a DataGridView Heres the critical part

[Code]...

View 1 Replies

Disposing DataGridViewComboBoxColumn.Datasource Throws Exception?

Sep 17, 2009

I remove the datagridviewcomboboxcolumn from the datagridview and dispose it. When I go to dispose of the datatable that is the datasource to the comboboxcolumn an ArgumentOutOfRangeException is thrown from the datagridview. Apparently the datagridview is still handling events for datagridviewcomboboxcells for comoboboxcolumns that have been removed from the datagridview.

View 8 Replies

FileStream Byte() Array Throws OutOfMemoryException?

Jul 2, 2010

I want to send files to my SQL server database. It works on smaller files, but when I try to send a 323MG file my byte array throws a OutOfMemoryException.Here is my code where the error happens...

Dim MediaFile As New FileInfo(txtFileName.Text)
Dim br As New IO.BinaryReader(New IO.FileStream(txtFileName.Text, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read, CInt(MediaFile.Length)))[code].....

The length of the file is 339476208.When I create a BinaryReader object and pass it in a Filestream object for the file that I am wanting to send to the database through FILESTREAM. I pass the length of the file to the byte array and I get a OutOfMemoryException.I have read in several places that the solution is to break it up into byte array chunks.

View 8 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved