datagridview

Gridview export to excel - Formatting problems

无人久伴 提交于 2020-01-16 18:40:31
问题 I am not sure about what is going on here. I use this button event to export data from datagridview to excel and the data get exported, file saved, etc.., so it looks like is working fine to me. private void button2_Click(object sender, EventArgs e) { Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing); Microsoft.Office.Interop.Excel._Worksheet worksheet = null;

DataGridViewComboBoxColumn value change not changing RowState to modified

ぐ巨炮叔叔 提交于 2020-01-16 16:27:59
问题 I have added a lookup combobox to my datagridview. Any changed to an existing row or adding a new row changed the value in RowState on save to Modified or Added. except changing a value in the combobox. On save, the RowState remains as unmodified. the code i use to add the combobox is. DataGridViewComboBoxColumn cbQualification = new DataGridViewComboBoxColumn(); cbQualification.HeaderText = "Course Code"; DataSet myDataSet = GetData.GetCoursesData(); cbQualification.DataSource = myDataSet

DataGridViewComboBoxColumn value change not changing RowState to modified

泄露秘密 提交于 2020-01-16 16:26:07
问题 I have added a lookup combobox to my datagridview. Any changed to an existing row or adding a new row changed the value in RowState on save to Modified or Added. except changing a value in the combobox. On save, the RowState remains as unmodified. the code i use to add the combobox is. DataGridViewComboBoxColumn cbQualification = new DataGridViewComboBoxColumn(); cbQualification.HeaderText = "Course Code"; DataSet myDataSet = GetData.GetCoursesData(); cbQualification.DataSource = myDataSet

C# DataGridView doesn't show data on other form [duplicate]

こ雲淡風輕ζ 提交于 2020-01-16 09:05:30
问题 This question already has answers here : How to access Form1 Function from Form2 without creating new Form(); (1 answer) I would like to control Form1 from Form2 (2 answers) Closed 2 years ago . I have two Windows Forms ( Form1 and Form2 ). Form1 has a button ( openfrm2 ) and a datagridview ( dataGridView1 ). Form2 has a textbox ( sql_textbox ) and a button ( button1 ). Clicking on openfrm2 opens Form2 , then I'm writing an SQL query in sql_textbox to view a table in a Postgres database and

Bug in DataGridView - simpel datasource, List<generic>?

与世无争的帅哥 提交于 2020-01-16 07:06:01
问题 If i run this code the application will crash, and i dont understand why, it seemes to me its a bug - or is it? Steps: place a System.Windows.Forms.DataGridView on a form. Define a datasource class: public class SomeClass { public SomeClass() { col1 = string.Empty; Col2= string.Empty; } public string col1 {get;set;} public string Col2 { get; set; } } //Declare new. (0 elements) private List<SomeClass> _col = new List<SomeClass>(); //First run this private void button1_Click(object sender,

Bug in DataGridView - simpel datasource, List<generic>?

本秂侑毒 提交于 2020-01-16 07:05:05
问题 If i run this code the application will crash, and i dont understand why, it seemes to me its a bug - or is it? Steps: place a System.Windows.Forms.DataGridView on a form. Define a datasource class: public class SomeClass { public SomeClass() { col1 = string.Empty; Col2= string.Empty; } public string col1 {get;set;} public string Col2 { get; set; } } //Declare new. (0 elements) private List<SomeClass> _col = new List<SomeClass>(); //First run this private void button1_Click(object sender,

Very simple C# program generates a `NullReferenceException was unhandled` error

◇◆丶佛笑我妖孽 提交于 2020-01-16 05:09:10
问题 I have a simple WinForm that I'm using to try to help me with ADO.NET. It has a datagridview I have added a compact sql server database to the project called experiment.sdf In the App.config file I have added the following. I used a previous project app file to base this on so maybe there's an error in here?: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> </configSections> <connectionStrings> <add name="DatabaseDGVexperiments.Properties.Settings

Delete row from datagridview

做~自己de王妃 提交于 2020-01-16 00:55:09
问题 I having problem on deleting a row of data returned by a search query. I wish the user can select whichever row of data and click on the delete button [button1_click] to delete it from DB. This is a windows form application. Hope you can advise me. Thanks a lot. Below is my code public partial class Search : Form { public Search() { InitializeComponent(); string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Project\DB_Booking.mdb;"; DataTable ds = new DataTable(); using (var cn

How to display serial number in datagridview?

久未见 提交于 2020-01-16 00:39:39
问题 i am using windows application with C#. I want to display Serial number in datagridview. 回答1: You need to bind DataBindingComplete event of datagridview. private void gridStateZone_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { LoadSerial(gridStateZone); } private void LoadSerial(DataGridView grid) { foreach (DataGridViewRow row in grid.Rows) { grid.Rows[row.Index].HeaderCell.Value = string.Format("{0} ", row.Index + 1).ToString(); row.Height = 25; } } It's work

Powershell DataGridView - looping through rows in checkbox column to see if checked

六月ゝ 毕业季﹏ 提交于 2020-01-15 20:14:14
问题 I'm trying to create a powershell form that will get all processes into a datagridview (which works OK so far). I'm then adding an additional column infront of the datasource with each row as a checkbox. I'd then like to press a button on my form which starts the Function called Do-Grid, and it is meant to go through and see which checkboxes in this first column have been checked. And this is where I get stuck. I'm unable to figure out how to loop through each row/cell only in this column and