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.
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.
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.
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
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.
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".
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?
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
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?
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.
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.
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]
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()
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
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
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.
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.
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..."
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?
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.
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
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.
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.