Export DataGridView to Excel File

Can you say me, how can i save the contents of DataGridView to Exel File with the Formatting cells Backcolor/Forecolor? I have DGV like this: And when I try to Export Data to Excel I get the data, but without Forecolor, I have tried a several of ways, but it does not work! Beforehand Thank you! private void btnExport_Click(object sender, EventArgs e) { SaveFileDialog sfd = new Save

将DataGridView导出到Excel文件

你能说我,我怎么能保存DataGridView内容格式化单元格Backcolor / Forecolor的Exel文件? 我有这样的DGV: 当我尝试将数据导出到Excel时,我获取了数据,但没有使用Forecolor,我尝试了几种方法,但它不起作用! 事先谢谢! private void btnExport_Click(object sender,EventArgs e){ SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Excel Documents (*.xls)|*.xls"; sfd.FileNam

Accessing string from another Form

Hello I have datagridview in form1 and through form1 I open form2 and through form2 I open form3 and string named vyber_ID_K placed in Form1 needs to be accessed in Form3 (I need to get its value in Form3) this is placed on button click in form1 form2 a = new form2 ("Novy"); string vyber_IDK = (string)dataGridView1.CurrentRow.Cells["ID_K"].Value.ToString(); a.vyber_ID_K = vybe

从另一个窗体访问字符串

您好我有form1和form1 datagridview我打开form2和通过form2我打开form3和string named vyber_ID_K放置在Form1需要在Form3中访问(我需要在Form3中获取它的值) 这放在form1中的按钮单击 form2 a = new form2 ("Novy"); string vyber_IDK = (string)dataGridView1.CurrentRow.Cells["ID_K"].Value.ToString(); a.vyber_ID_K = vyber_IDK; a.Show(); a.Closed += klient_Closed; 我想vyber_I

datagridview in form1 automatic refresh after insert from form2

I have small issue, I have datagridview in form1 to which I insert data from form2 using SQL commands, but after button click which includes INSERT command the newly inserted value doesn't appear in form1's datagridview. Is there any way to solve this ? So I had to make refresh button in form1 so I can refresh it every time something is inserted. Thanks in advance. This is the inse

form2中的datagridview在从form2插入后自动刷新

我有一个小问题,我在Form1中使用SQL命令插入data2中的datagridview,但在包含INSERT命令的按钮单击后,新插入的值不会出现在form1的datagridview中。 有什么办法可以解决这个问题吗? 所以我不得不在form1中刷新按钮,这样每次插入内容时都可以刷新它。 提前致谢。 这是form2中按钮单击的插入代码:private void btn_zaj_uloz_Click(object sender,EventArgs e){ SqlCommand prikaz = new SqlCommand

Binding to a ContentPresenter's visual elements/children from outside

First a brief "abstracted" short version of my problem. Probably not needed to discuss a solution, but below some further "optional" infos of the real underlying problem I'm having, just to understand the context. So: I have a ContentPresenter using a DataTemplate to generate its layout for bound items. Now, outside of this contentpresenter, I'm trying to bind with

从外部绑定到ContentPresenter的视觉元素/子项

首先是一个简短的“抽象”简短版本的问题。 可能不需要讨论一个解决方案,但是下面有一些我选择的真正基础问题的进一步“可选”信息,只是为了理解上下文。 所以:我有一个ContentPresenter使用DataTemplate为绑定项目生成其布局。 现在,除了这个contentpresenter之外,我试图在该内容展示者的名称内通过名称进行绑定。 假设下面的伪XAML(MainTextBlock的绑定在实践中不起作用): <TextBlock Text="{Binding Text, El

How can I change a wpf Databound grid cell based on the cell value?

I'm relatively new to WPF, and am trying to change certain grid cells where the bound values are decimal zeros. The intent is to leave the cell blank where the cell has 0's. For example, if the TranDeposit column is zeros, I would like to change that to blanks. In ASP.NET this is very possible by using the DataBound event. The XAML code follows: <DataGrid x:Name="transactionsDataG

如何根据单元格值更改wpf Databound网格单元格?

我对WPF比较陌生,并且正在尝试更改某些网格单元格,其边界值为十进制零。 其目的是将单元格留在单元格为0的位置。 例如,如果TranDeposit列是零,我想将其更改为空白。 在ASP.NET中,这很可能通过使用DataBound事件。 XAML代码如下: <DataGrid x:Name="transactionsDataGrid" Grid.Row="3" AutoGenerateColumns="False" EnableRowVirtualization="True" ItemsSource="{Binding}" RowDetailsVisibil

How to edit an unbound cell in a bound DataGrid?

So I have a DataGrid bound to a data source (using ADO.NET), I created a new local column (it doesn't need to exist in database). I do some calculations and then put the results in that column. Now, I know how to edit/access the bound cells via DataSet, but I don't know how to do it for the cells of that new column because it's not in the DataSet. I want to iterate each row and edi

如何编辑绑定的DataGrid中的未绑定单元格?

所以我有一个绑定到数据源的DataGrid(使用ADO.NET),我创建了一个新的本地列(它不需要存在于数据库中)。 我做了一些计算,然后将结果放在该列中。 现在,我知道如何通过DataSet编辑/访问绑定单元格,但我不知道如何为新列的单元格执行此操作,因为它不在DataSet中。 我想迭代每一行并编辑新列的单元格值。 任何帮助表示赞赏。 对于来到这个页面的其他人,将下面的属性添加到我的DataGrid的声明中对我来说有个诀窍: Se

Databinding in WinForms performing async data import

I have a scenario where I have a collection of objects bound to a datagrid in winforms. If a user drags and drops an item on to the grid, I need to add a placeholder row into the grid and kick off a lengthy async import process. I need to communicate the status of the async import process back to the UI, updating the row in the grid and have the UI remain responsive to allow the user to edit th

WinForms中的数据绑定执行异步数据导入

我有一个场景,我有一个绑定到winform中的数据网格的对象的集合。 如果用户将一个项目拖放到网格上,我需要在网格中添加一个占位符行,并启动冗长的异步导入过程。 我需要将异步导入过程的状态反馈回UI,更新网格中的行,并让UI保持响应以允许用户编辑其他行。 这样做的最佳做法是什么? 我目前的解决方案是:将BindingList的线程安全实现绑定到网格,并填充在网格中显示为行的对象。 当用户将一个项目拖放到网格上时,我

Calculate colours for points along an arbitrary gradient

I'm trying to write an 'apply gradient' function, which takes a bunch of points and a linear gradient and calculates the colour for each point. I have something like this (given an array of points and a gradient defined by two points start and end ): struct Colour { float red; float green; float blue; }; struct Point { int x; int y; Colour colour; }; Point points[total

计算沿任意渐变的点的颜色

我正在尝试编写一个“应用渐变”函数,该函数需要一些点和一个线性渐变并计算每个点的颜色。 我有这样的事情(给定一个points的数组和由两个点start和end定义的梯度): struct Colour { float red; float green; float blue; }; struct Point { int x; int y; Colour colour; }; Point points[total_points] = { ... }; Point start = { ... }; Point end = { ... }; for (int i=0; i<total_points; i++)

help with second level cache using NHibernate and memcached

我如何读取/写入缓存的时间周期,即10秒,然后将更改提交到数据库? I'm not 100% sure for NHibernate but Hibernate 2nd level cache does NOT offer Write-Behind caching, Hibernate just directly writes to the database. I think the same applies to NHibernate. In other words, what you'd like to do is IMO not possible, at least not without modifying NHibernate to write to the 2nd level cache and

使用NHibernate和memcached帮助二级缓存

我如何读取/写入缓存的时间周期,即10秒,然后将更改提交到数据库? 我对NHibernate并不是100%肯定的,但Hibernate 2nd级缓存不提供Write-Behind缓存,Hibernate只是直接写入数据库。 我认为这同样适用于NHibernate。 换句话说,你想要做的是IMO不可能,至少不是修改NHibernate写入二级缓存和一个持久的异步数据库队列。 但这将是一个非常微不足道的变化,不会在短期内发生。 您所做的更改将在事务提交时被提交到数据库,

NHibernate.MappingException: No persister for: XYZ

Now, before you say it: I did Google and my hbm.xml file is an Embedded Resource. Here is the code I am calling: ISession session = GetCurrentSession(); var returnObject = session.Get<T>(Id); Here is my mapping file for the class: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="HQData.Objects.SubCategory, HQD

NHibernate.MappingException:没有persister:XYZ

现在,在你说出来之前:我做了 Google,我的hbm.xml文件是嵌入式资源。 这是我打电话的代码: ISession session = GetCurrentSession(); var returnObject = session.Get<T>(Id); 这是我的类的映射文件: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="HQData.Objects.SubCategory, HQData" table="SubCategory" lazy="true">