DGV - empty cell

DGV - empty cell

ZEH1985
Contributor Contributor
164 Views
0 Replies
Message 1 of 1

DGV - empty cell

ZEH1985
Contributor
Contributor

Hello,

 

I have a problem with a DataGridView(DGV).

I read the iProperties of an idw and transfer them to the DGV. I don't use a "DataSet" because somehow I can't get it to work. This is working fine so far.

My program flow when exiting the form is as follows:

- Delete all custom iProps

- Save all lines of the DGV as custom iProps

 

If I change the values against new values, it works. But as soon as I delete the value for an iProp and there is nothing in the field, I get an error message

 

Informationen über das Aufrufen von JIT-Debuggen
anstelle dieses Dialogfelds finden Sie am Ende dieser Meldung.

************** Ausnahmetext **************
System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
bei XXX_AddIn.frm_iPropIdwALG.SaveFormALG()
bei XXX_AddIn.frm_iPropIdwALG.frm_cmd_ok_Click(Object sender, EventArgs e)
bei System.Windows.Forms.Control.OnClick(EventArgs e)
bei System.Windows.Forms.Button.OnClick(EventArgs e)
bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
bei System.Windows.Forms.Button.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 

If I write a space-char in the field as a user, I don't get the error either. So I thought to myself that I would then add one myself to all fields where there are no values -> without success.

Here is my current code:

' alle Custom iProps aus der Datei löschen
iPropManagement.DeleteAllCustomIprops(oDoc)

Dim sStreamLast As String = ""
Dim sRowPropName As String = ""
Dim sRowPropValue As String = ""
' iProperties in Datei schreiben
For Each row As DataGridViewRow In DGVProp.Rows

'MsgBox(row.Cells(0).Value.ToString & "- " & row.Cells(1).Value.ToString)

sRowPropName = row.Cells(0).Value.ToString
sRowPropValue = row.Cells(1).Value.ToString
If sRowPropValue = "" Then
sRowPropValue = " "
End If

MsgBox("Name:" & sRowPropName & " - Wert: " & sRowPropValue)
iPropManagement.Edit(oDoc, sRowPropName, sRowPropValue)

'in Textdatei speichern
MsgBox("vor dem stream")
sStreamLast = sStreamLast & sRowPropName & "|" & sRowPropValue & vbCrLf
MsgBox("nach dem stream")
Next

 

But the error persists. It seems that the for loop has a problem with this. Does anyone know the problem and has a solution for me?

 

Thank you in advance for any ideas

0 Likes
165 Views
0 Replies
Replies (0)