Halli Hallo,
Ich bin recht neu imn C# programierung und bin schon auf ein Problem gestossen das ich anscheinend nicht gelöst bekomme.
Unzaw habe ich eine Tabbel in einem Word Dokument erstellt,
C#-Quelltext
1: 2: 3: 4:
| . . wrdRng.Tables.Add(oDoc.Paragraphs[2].Range, 70, 6, ref oMissing, ref oMissing); oTable = oDoc.Tables[1]; |
die ich im nachhinein Formatieren und mit Text füllen möchte.
Soweit so gut. Wenn ich die Oberste Spalte beschrifte und mit dem dazügehörigen Stye ( Schfift / frabe / größe ) versehe ist alle noch bestens.
Dann Verbinde ich die beiden ersten Zellen der Reihe 4 und 5.
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10:
| . . row += 4; oTable.Cell(row, 1).Merge(oTable.Cell(row, 2)); oTable.Cell(row+1, 1).Merge(oTable.Cell(row+1, 2)); oTable.Rows[row+1].Cells[1].Range.Text = text; . . . |
Wenn ich aber dann noch das mache :
C#-Quelltext
1: 2:
| oTable.Cell(row, 1).Merge(oTable.Cell(row+1, 1)); |
kann ich dannache keine Zeile ( row) mehr
ansprechen .... Sobald ich versuche auf eine Zeile zuzugreifen gibt es eims auf die Backen !
Fehler Meldung :
"Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt."
ich poste hir auch mal den gesamten dump ... falls jemand damit was anfangen kann
Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27:
| System.NullReferenceException wurde nicht behandelt. Message="Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt." Source="WindowsApplication3" StackTrace: bei WindowsApplication3.Form1.button2_Click(Object sender, EventArgs e) in G:\Users\leo\Documents\Visual Studio 2005\Projects\WindowsApplication3\WindowsApplication3\Form1.cs:Zeile 132. 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.Control.ControlNativeWindow.OnMessage(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.Run(Form mainForm) bei WindowsApplication3.Program.Main() in G:\Users\leo\Documents\Visual Studio 2005\Projects\WindowsApplication3\WindowsApplication3\Program.cs:Zeile 17. bei System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() bei System.Threading.ThreadHelper.ThreadStart_Context(Object state) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Threading.ThreadHelper.ThreadStart() |
Moderiert von Christian S.: C#-Tags hinzugefügt