datagridview

How to scroll DataGridView in pixel increments

瘦欲@ 提交于 2020-03-14 15:37:17
问题 My original approach was to enclose my DataGridView inside a panel, set its height outside the boundary of the panel and then change control panel's scroll bar position. However, I just found out that the number of rows inside my DataGridView would reach 2000, which forces me to size the DataGridView to at least: 65px (row height) x 2,000 = 130,000px. The maximum allowed size for a DataGridView control on my 64bit machine is 65,535. Anyone can think of a way around this issue? 回答1: Hmm, no,

导出DataGridView显示列数据到Excel中:)

被刻印的时光 ゝ 提交于 2020-03-12 09:26:51
/// <summary> /// DataToExcel 的摘要说明。 ///代码很简单就不多说什么了。:)大家自己看吧 ///参考了堂子里一个大侠的代码,具体地址忘记了。这里说声不好意思。 /// </summary> public class DataToExcel { const string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0;"; public DataToExcel() { } /// <summary> /// /// </summary> /// <param name="dgv"></param> /// <param name="excelPath"></param> /// <returns></returns> public string DataGridViewToExcel(System.Windows.Forms.DataGridView dgv, string excelPath) { if (dgv == null) { return "DataGridView不能为空"; } object[] os = (object[])dgv.DataSource; int cols = dgv

C# Using data from DataGridView in a Chart

早过忘川 提交于 2020-03-05 04:14:09
问题 I have code that generates data in the DataGridView and I want to also push this to a chart from the same button click. Process: Text is put into a text box myInputBox then the button processButton is pressed to split the text up and output it to the DataGridView myOutputDGV the button has the following code: private void processButton_Click(object sender, EventArgs e) { List<string> mySplit = new List<string>(myInputBox.Text.Split(new string[] { "XN" }, StringSplitOptions.None));

Updated rows in DataGridView not reflecting in UI C# WinForms

无人久伴 提交于 2020-03-04 23:18:28
问题 I have a WinForms application & it has DataGridView. It has a form TaskPane. If I add any new row in the constructor it adds while at any other place it doesn't. public TaskPane(List<Tuple<string, string>> entities =null) { InitializeComponent(); tabTextForReview.BorderStyle = BorderStyle.FixedSingle; dgEntitiesForReview.Rows.Add("StaticKey", "StaticContent"); if (entities!= null) { foreach (var entity in entities) { dgEntitiesForReview.Rows.Add(entity.Item1, entity.Item2); // tried with -

在DataGridView中浏览shp图层的属性表[.dbf文件]

自作多情 提交于 2020-03-03 23:21:55
每次浏览shp图层的属性表时,总是使用ArcMap打开,比较麻烦。虽然网络中有小巧的DBF数据库浏览工具,也还是觉得有点大材小用。 下面的C#代码用来读取shp图层的属性表,并在DataGridView中显示,在VS 2005中调试通过,代码很简单。 OpenFileDialog ofdDBF = new OpenFileDialog(); ofdDBF.Filter = " 属性表文件(*.dbf)|*.dbf " ; if (ofdDBF.ShowDialog() == DialogResult.OK) { string OpenFileName = ofdDBF.FileName.Trim(); string dbfFilePath = Path.GetDirectoryName(OpenFileName); string dbfFileName = Path.GetFileName(OpenFileName); IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass(); IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(dbfFilePath, 0 ); IFeatureWorkspace pFeatureWorkspace

Why does DGV cause uncaught exception when removing item from DataSource?

佐手、 提交于 2020-03-03 07:33:34
问题 I have a WinForms application with a DataGridView that has its DataSource property set to a BindingSource (which in turn has its DataSource set to a BindingList). Everything works just fine, until I come to remove items from the BindingSource in response to a user request, the code I use for this is: try { // Get the item currently selected by the DGV var fc = (FooType)FooBindingSource.Current; // Remove the item from the binding source FooBindingSource.Remove(fch); } catch (Exception fault)

Why does DGV cause uncaught exception when removing item from DataSource?

China☆狼群 提交于 2020-03-03 07:33:30
问题 I have a WinForms application with a DataGridView that has its DataSource property set to a BindingSource (which in turn has its DataSource set to a BindingList). Everything works just fine, until I come to remove items from the BindingSource in response to a user request, the code I use for this is: try { // Get the item currently selected by the DGV var fc = (FooType)FooBindingSource.Current; // Remove the item from the binding source FooBindingSource.Remove(fch); } catch (Exception fault)

Why does DGV cause uncaught exception when removing item from DataSource?

感情迁移 提交于 2020-03-03 07:33:09
问题 I have a WinForms application with a DataGridView that has its DataSource property set to a BindingSource (which in turn has its DataSource set to a BindingList). Everything works just fine, until I come to remove items from the BindingSource in response to a user request, the code I use for this is: try { // Get the item currently selected by the DGV var fc = (FooType)FooBindingSource.Current; // Remove the item from the binding source FooBindingSource.Remove(fch); } catch (Exception fault)

Datagridview is completely hidden for bindingsource the second time

允我心安 提交于 2020-02-26 02:02:37
问题 private void populateListingGrid(){ try{ Dictionary<string, Object> responseMap = new Dictionary<string, object>(); PaginationList newContractDetailsListingMsDTO = getNewContractDetailsListingMsDTO(); ContractService createContractService = ContractServiceFactory.getInstance(); responseMap = createContractService.getContractListing(); contractList = responseMap["contractListingMsDTOs"] as List<NewContractListingMsDTO>; this.newContractListingMsDTOBindingSource.Clear(); if (contractList !=

Datagridview is completely hidden for bindingsource the second time

旧街凉风 提交于 2020-02-26 02:02:13
问题 private void populateListingGrid(){ try{ Dictionary<string, Object> responseMap = new Dictionary<string, object>(); PaginationList newContractDetailsListingMsDTO = getNewContractDetailsListingMsDTO(); ContractService createContractService = ContractServiceFactory.getInstance(); responseMap = createContractService.getContractListing(); contractList = responseMap["contractListingMsDTOs"] as List<NewContractListingMsDTO>; this.newContractListingMsDTOBindingSource.Clear(); if (contractList !=