Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
H

H Martins

@H Martins
About
Posts
3
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • System.NullReferenceException:
    H H Martins

    Hi. (I am Portuguese) ********UPDATE******* Looks like I found the problem In the first for() there was a 1 instead of an i. I realized that after increasing zoom level. I apologize. ************** I am a new-by to Visual Studio and C# classes and I am trying to extract a GridView content to a CSV format file. Handling and processing fields seems not too difficult but the extraction is fighting me. I run the compiler, the form shows up, I fill the grid clicking the fill button, it fills OK but when I press the button to export, I get: System.NullReferenceException: 'Object reference not set to an instance of an object.' System.Windows.Forms.DataGridViewCell.Value.get returned null. In both similar lines: writer.Write(dataGridViewMotor1.Rows[i].Cells[j].Value.ToString());

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.IO;

    namespace Stepping
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

        private void dataGridView1\_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
    
        }
    
        private void btnSave01\_MouseClick(object sender, MouseEventArgs e)
        {
            TextWriter writer = new StreamWriter(@"H:\\proj\\\_Programacao\\\_Arduino\\ArduinoHM\\Stepper\_Polling\_us\\WinApp\\M01.txt");
            
            for (int i = 0; 1 < dataGridViewMotor1.Rows.Count - 1; i++)
            {
                for (int j = 0; j < dataGridViewMotor1.Columns.Count; j++)
                {
                    if (j == 0)
                    {
                        writer.Write(dataGridViewMotor1.Rows\[i\].Cells\[j\].Value.ToString());  
                    }
                    else
                    {
                        writer.Write("," + dataGridViewMotor1.Rows\[i\].Cells\[j\].Value.ToString());
                    }
                }
            }
            writer.Close();
            MessageBox.Show("Data Exported");
        }
    
        private void btnFillTestData\_MouseClick(object sender, MouseEventArgs e)
        {
            // Line, Abs, Rel, X, C\_t, C\_i, C\_n, MinSpeed, MaxSpeed, Accel, Decel
            dataGridViewMotor1.Rows.Add(1,0, 120,0,0,0,0, 10, 100, 0.9, 0.9 );
            dataGridViewMotor1.Rows.Add(2,0,12
    
    Database csharp css visual-studio linq graphics

  • General advice about simple table storage.
    H H Martins

    Thank you very much. I have been fighting Visual Studio for a couple hours and managed to create the basic GridView configuration. Although in the much simpler Arduino environment, I am familiarized with C and I have recently written a couple Classes ( I should have started before :) ). Nevertheless helped by some web browsing I suppose I can handle the code behind the forms. I decided to leave Excel for later and concentrate in creating and reading CVS files.

    Then EPPlus or LinqToExcel might be more suitable.

    Thank you again.

    Database database csharp sql-server visual-studio sysadmin

  • General advice about simple table storage.
    H H Martins

    I need some general advice. (My natural language is Portuguese). I need to do a small Windows desktop application to fill (by hand) a single table with, say, a maximum of one thousand records of some 20 fields for later manipulation. About 15 years ago I have done a database application in Access 2003 whose tables were separately stored (same folder) without a SQL server. I would like to stay away from Access and use Visual Studio Community and, also, stay away from a SQL server or the need to have it installed in the computers where the application will run. I suppose that to crate a table in a form must not be complicated (I have already played a little bit with that) but I am at a lost about storing the table on disk without SQL database/server. All examples I found in the Web involve SQL servers. Simplifying, I need to make a standalone application able to create, store and read a separate datafile. Saving the table in Excel format or similar would be acceptable because importing some data from excel could eventually be interesting. The application final output would be some ASCII file with delimited data but this file is not supposed to be read by the application. At the moment I am flying around without a place to land. Any help would be greatly appreciated. H. Martins

    Database database csharp sql-server visual-studio sysadmin
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups