datagridview

How to save changes from DataGridView to the database?

China☆狼群 提交于 2020-01-22 02:34:08
问题 I would like to save the changes made to a DataGridView into the database MS SQL CE, but i can't, the changes are not saved to the database.... This the code (VB.net): Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) handles MyBase.Load Dim con As SqlCeConnection = New SqlCeConnection(@"Data Source=C:\Users\utente\Documents\test.sdf") Dim cmd As SqlCeCommand = New SqlCeCommand("SELECT * FROM mytable", con) con.Open() myDA = New SqlCeDataAdapter(cmd) Dim

c# window form DataTable with Image column Sorting

梦想与她 提交于 2020-01-22 02:32:25
问题 I have DataGridView and I set DataSource of datagridview by using DataTables. DataTable dt = new DataTable(); dt.Columns.Add("Image",typeof(Bitmap)); dt.Columns.Add("Col2", typeof(string)); dt.Columns.Add("Col3", typeof(string)); dt.Columns.Add("Col4", typeof(string)); dt.Columns.Add("Col5", typeof(string)); int currentrow = 0; foreach (Dev d in Devs) { dt.Rows.Add(dt.NewRow()); Bitmap bmp = Test(d); dt.Rows[currentrow][0] = bmp; dt.Rows[currentrow][1] = d .ID; dt.Rows[currentrow][2] = d

DataGridView - how can I make a checkbox act as a radio button?

一个人想着一个人 提交于 2020-01-21 12:16:13
问题 I have a Windows Forms app that displays a list of objects in a DataGridView. This control renders bool values as checkboxes. There's a set of three checkboxes in the object properties that are mutually exclusive. At most one of them can be true. Accordingly I'd like the checkboxes to act like a set of radio buttons. Just a side remark from the old guy: I think people these days don't even know why these are called radio buttons. In the old days a radio in a car had 4 or 5 buttons, and

How to populate a DataGridView based on Excel search results and remove blank headers from the DataGridView?

荒凉一梦 提交于 2020-01-21 09:05:08
问题 I have 1 Form with 1 TextBox where an user will type ProductId(FCID) , press the enter key and, based on that, I want to populate my DataGridView with the results of a search. There are 2 problems here: How do I filter records from Excel based on user entered FCID ? While binding the DataSource from Excel, how to remove blank records as shown in the second image? Code: private void txtProductId_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string pathName = txtFilePath

How to populate a DataGridView based on Excel search results and remove blank headers from the DataGridView?

馋奶兔 提交于 2020-01-21 09:05:07
问题 I have 1 Form with 1 TextBox where an user will type ProductId(FCID) , press the enter key and, based on that, I want to populate my DataGridView with the results of a search. There are 2 problems here: How do I filter records from Excel based on user entered FCID ? While binding the DataSource from Excel, how to remove blank records as shown in the second image? Code: private void txtProductId_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string pathName = txtFilePath

How to populate a DataGridView based on Excel search results and remove blank headers from the DataGridView?

百般思念 提交于 2020-01-21 09:05:07
问题 I have 1 Form with 1 TextBox where an user will type ProductId(FCID) , press the enter key and, based on that, I want to populate my DataGridView with the results of a search. There are 2 problems here: How do I filter records from Excel based on user entered FCID ? While binding the DataSource from Excel, how to remove blank records as shown in the second image? Code: private void txtProductId_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string pathName = txtFilePath

Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound

送分小仙女□ 提交于 2020-01-20 06:51:22
问题 I have a grid and when data is loaded in grid; I simply select a row and press edit button. On edit, new sub form is opened and values of row's cells are passed to controls on sub form. But, when I change some values on sub form and save them to be replaces in grid the error comes to me: Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound . What is cause of this error and how to overcome this. 回答1: The cause is that "Rows cannot be

Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound

雨燕双飞 提交于 2020-01-20 06:50:09
问题 I have a grid and when data is loaded in grid; I simply select a row and press edit button. On edit, new sub form is opened and values of row's cells are passed to controls on sub form. But, when I change some values on sub form and save them to be replaces in grid the error comes to me: Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound . What is cause of this error and how to overcome this. 回答1: The cause is that "Rows cannot be

C# DataGridView控件中数据导出到Excel

自古美人都是妖i 提交于 2020-01-19 10:41:11
方法一: 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.Reflection; using Microsoft.Office.Interop.Excel; namespace TestEXCLE { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { _DataGridView = this.dataGridView1; ExportToExcel("www"); } private DataGridView _DataGridView; private string _FileName = ""; ///// <summary> ///// 构造函数 ///// </summary> ///// <param name=

WinForms DataGridView - databind to an object with a list property (variable number of columns)

醉酒当歌 提交于 2020-01-18 22:41:54
问题 I have a .NET class I'd like to show in a DataGridView, and the default databinding - setting the DGV's DataSource to the object - produces 90% of my requirements (i.e. it's outputting the public properties correctly and I can add sorting easily). However, one of the properties I need to bind is a List which contains data which needs to be in separate columns after the other databound items. I'm stuck on how best to implement this. My class looks something like this: public class BookDetails