Hello,
Is this a bug?
Is there some kind of work around?
I want to add default values for a few columns in my datagridview
I found the "DefaultValuesNeeded" event for the datagridview
I gave it a try using the example given in
http://msdn2.microsoft.com/en-us/lib...uesneeded.aspx
Here is my code
\\
Private Sub dgvDeviceTypes_DefaultValuesNeeded(ByVal sender As
Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs)
Handles dgvDeviceTypes.DefaultValuesNeeded
'enter default values into lkpDeviceTypes
With e.Row
.Cells("dtHide").Value = False
.Cells("dtOrd").Value = 0
.Cells("bMachType").Value = True
End With
End Sub
//
I get the following error;
-----------------------
Column named rEditedBy cannot be found.
Parameter name: columnName
-----------------------
Here is my table;
pkDeviceTypeId smallint
DeviceName varchar(20)
Prefix char(4)
bMachType bit
dtOrd tinyint
dtHide bit
Below is the text of the error - Notice that the code cannot find the
column name. It seems that it thinks the column name is "columnName";
System.ArgumentException was unhandled
Message="Column named rEditedBy cannot be found.
Parameter name: columnName"
ParamName="columnName"
Source="System.Windows.Forms"
StackTrace:
at
System.Windows.Forms.DataGridViewCellCollection.ge t_Item(String
columnName)
at
QmsUI.f080AdminSetup.dgvLaborCostCodes_DefaultValu esNeeded(Object
sender, DataGridViewRowEventArgs e) in D:\DBuchanan MyDocuments\Visual
Studio 2005\Projects\Qms_01\QmsUI\Form1.vb:line 287
at
System.Windows.Forms.DataGridView.OnDefaultValuesN eeded(DataGridViewRowEventArgs
e)
at
System.Windows.Forms.DataGridView.OnRowEnter(DataG ridViewCell&
dataGridViewCell, Int32 columnIndex, Int32 rowIndex, Boolean
canCreateNewRow, Boolean validationFailureOccurred)
at
System.Windows.Forms.DataGridView.SetCurrentCellAd dressCore(Int32
columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean
validateCurrentCell, Boolean throughMouseClick)
at System.Windows.Forms.DataGridView.OnCellMouseDown( HitTestInfo
hti, Boolean isShiftDown, Boolean isControlDown)
at
System.Windows.Forms.DataGridView.OnCellMouseDown( DataGridViewCellMouseEventArgs
e)
at System.Windows.Forms.DataGridView.OnMouseDown(Mous eEventArgs
e)
at System.Windows.Forms.Control.WmMouseDown(Message& m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.DataGridView.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationCo ntext
context)
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[]
commandLine)
at QmsUI.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object
state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Is this a bug?
Is there some kind of work around?
thank you,
dbuchanan