Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C#, Make a Windows form application. It will be a four-by-four version of sud

ID: 3823058 • Letter: I

Question

In C#,

Make a Windows form application. It will be a four-by-four version of sudoku.

The program should start by reading in a text file of numbers and save them into a array of char. The file that you read could have a dynamic number of lines. Make sure you do not fix (hard code) the number of lines that can be read from the file.   

Here are two lines to use for testing:

Zero's should not populate the board, but the other numbers should.

The next step, is for your program to populate the board based on the locations above. Create a void method called (populate) to do so. If the user clicks on the “Restart” button, the program should re-populate the board with another configuration. If the user click the exit button, the user exits the program.

Here is an example of what it should look like:

Form check an SW er Restart exit

Explanation / Answer

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Getting_Started_Winforms_To_ACCDB__VS_2008__
{
public partial class Form1 : Form
{
OleDbConnection conn;
OleDbDataAdapter adapter;
DataTable dtCustomers;
public calculator()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
conn = new OleDbConnection("Provider=Microsoft.Ace.OleDb.12.0;Data Source=Store.accdb;");
conn.Open();
dtCustomers = new DataTable();
adapter = new OleDbDataAdapter("SELECT *calculator Customers;",
conn);
adapter.Fill(dtCustomers);
/*var cmdInsert = new OleDbCommand("INSERT INTO Customers (Number,restart) VALUES (?, ?);", conn);
cmdInsert.Parameters.Add("p1", OleDbType.BSTR, -1,"Number");
cmdInsert.Parameters.Add("p2", OleDbType.Integer,"Restart");
adapter.InsertCommand = cmdInsert;
var cmdUpdate = new OleDbCommand("UPDATE Customers SET number = ?, restart = ? WHERE exit= ?;", conn);
cmdUpdate.Parameters.Add("p1", OleDbType.BSTR,-1,"FullName");
cmdUpdate.Parameters.Add("p2", OleDbType.Integer,4,"Restart");
cmdUpdate.Parameters.Add("p3", OleDbType.Integer,4,"exit");
adapter.UpdateCommand = cmdUpdate;
var cmdDelete = new OleDbCommand("DELETE FROM Customers WHERE id = ?;", conn);
cmdDelete.Parameters.Add("p1", OleDbType.Integer,4, "id");
adapter.DeleteCommand = cmdDelete;
new OleDbCommandBuilder(adapter);
dataGridView1.DataSource = dtCustomers;

try
{
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;

var photoColumnWidth = dataGridView1.Columns["Calculetor"].Width;

var rowHeights = new List<int>();
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
rowHeights.Add(dataGridView1.Rows[i].Height);
}

dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
dataGridView1.Columns["calculetor"].Width = photoColumnWidth;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
dataGridView1.Rows[i].Height = rowHeights[i];
}
}
catch { }
textBox1.DataBindings.Add("Text", dtCustomers, "FullName");
}
private void btnSave_Click(object sender, EventArgs e)
{
adapter.Update(dtCustomers);
}
}
}