datagridview

Fill dataGridView thank's to backGroundWorker

独自空忆成欢 提交于 2020-01-13 10:05:31
问题 I have this code snippet: private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { remplirDataGrid(); } private void frmChercherActesLoad(object sender, EventArgs e) { backgroundWorker1.RunWorkerAsync(); } private void remplirDataGrid() { dataGridView1.DataSource = ActeServices.getAllActes(0, 40); dataGridView1.Columns[0].Visible = false; dataGridView1.Columns[1].HeaderText = "Code acte"; dataGridView1.Columns[2].HeaderText = "Désignation"; dataGridView1

.Net DataGridView “Index 0 does not have a value.”

别等时光非礼了梦想. 提交于 2020-01-13 04:09:59
问题 I am having trouble with a DataGridView. I have a collection of 3 Items bound to the grid, when trying to delete one of the items and reload the grid. If have code of If (dlg.ShowDialog() = DialogResult.OK) Then 'Show dialog with grid on it End If On the opened dialog, I delete an item from the grid (which should in turn, delete the item from the collection, and re-load the grid), and it returns to the "If (dlg.show..." line, with the error of "A first chance exception of type 'System

How can one disable the first autoselect in a VS datagridview?

柔情痞子 提交于 2020-01-12 07:43:23
问题 I have created an application in Visual Studio (C#) that makes use of a datagridview. Now, when I assign the DataSource of that datagridview, it automatically selects the first row, and executes my code for selection. Since I frequently reassign that datasource, this is not desireable. Is there any way to change it so it doesn't automatically make that first select, and only relies on the user's selections? Thanks! In response to the comment of Darshan Joshi: Apart from the auto-generated

winform .net best way if you want to display images in a datagridview

妖精的绣舞 提交于 2020-01-11 14:22:09
问题 net webdeveloper and usually don't make any win32 apps. but now i have to. i have a list with about 2000 entries. each entry should be displayed as, a label with textbox another label and picture. i have made this with a flowlayoutpanel and i did a foreach on the entries to make a panel for each entry with the label, textbox, label and a picturebox. now i have rendering issues when it comes above 1000 entries. so i have read that i should use a listview or datagridview. now i have a

C# Winform DataGridView 公共分页实现

醉酒当歌 提交于 2020-01-11 13:46:40
Demo的界面 我利用事件委托事件,仿http://www.cnblogs.com/huyong/写的公共分页用户控件 C#代码 #region 版权信息 /*---------------------------------------------------------------------* // 项目 名称:《Winform分页控件》 // 文 件 名: Pager.cs // 描 述: 分页控件 // 作 者:kwon yan *----------------------------------------------------------------------*/ #endregion using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace HuishengFS.Controls { /**/ /// <summary> /// 申明委托 /// </summary> /// <param name="e"></param> ///

How to select/unselect all child check box based on the header checkbox of parent grid

我是研究僧i 提交于 2020-01-11 13:20:16
问题 I am Developing a web application which consists of Datagrid nested with another datagrid. In Parent Grid i have a Check box in the header template and in the child grid have another check box in the item template. Functionality is: 1.If i click on the parent check box all items in the child grid should be get checked and vice versa. 2. I have amount column in the child grid , i need the sum of checked row's amount to be displayed in the textbox. For EG: in my child grid i have 3 column with

Change the datagridview colour based on date

时光总嘲笑我的痴心妄想 提交于 2020-01-11 13:15:07
问题 i got a datagridview which displays data from database(MS Access) the datagridview display the data correctly.. now i want to change the colour of the dgvReminder's row to yellow if current date is less than 2 days to the Date_Of_Pickup. Date_Of_Pickup is in this format = 19-Dec-2013 So far i have test this code :- Private Sub Home_Load(sender As Object, e As EventArgs) Handles MyBase.Load For i As Integer = 0 To dgvReminder.Rows.Count - 1 If dgvReminder.Rows(i).Cells("Quantity").Value < 2

Programmatically perform click on a DataGridView Button Cell from another Button

空扰寡人 提交于 2020-01-11 11:48:45
问题 I have a question regarding DataGridView control in .NET. I inserted a DataGridView from the toolbox and I connected it with a database that I setup in access. Then I added a column with buttons from the edit columns of the DataGridView tasks panel. The click events of the DataGridView buttons work without a problem! I want to perform a click on DataGridView button programmatically when I click another button outside of the DataGridView . How should I do this? The code of the DataGridView is:

How to achieve multi line header in DataGridView using property grid?

只愿长相守 提交于 2020-01-11 07:34:10
问题 I am trying to give the multi line header text in property grid for the DataGridView, I have used \n , \r\n but neither worked to get the header text in multiple lines. Is there a way other than setting the width of the column and leaving spaces to get this working using the property grid? 回答1: If possible use Environment.NewLine (which is \r\n in Windows), and set the Grid column DefaultCellStyle.WrapMode property to DataGridViewTriState.True . dataGridView.Columns[0].DefaultCellStyle

“BindingSource cannot be its own data source” - error when trying to reset the binding source from a method in another class

六眼飞鱼酱① 提交于 2020-01-11 05:06:30
问题 We are binding a DataGridview using BindingSource . So in the main thread we have given like this. class1BindingSource = new BindingSource(); class1BindingSource.DataSource = class1List; this.dataGridView1.DataSource = class1BindingSource; After that i have a placed a background worker in the form and is triggering in a button click. i.e. in the button click this.backgroundWorker1.RunWorkerAsync() In the BackgroundWorker DoWork Event i am trying to update the BindingSource and there by trying