datagridview

How to replace the HeaderCells of a DataGridView with custom headers?

◇◆丶佛笑我妖孽 提交于 2021-02-05 07:13:26
问题 When to replace a DataGridViewColumnHeaderCell with a custom HeaderCell (here: CustomDataGridViewColumnHeaderCell ), when the DataSource of a DataGridView is already set to a DataTable object and also preserve the text of the previous HeaderCell, which is set to the name of the corresponding Column of the DataTable? I have a custom header class for a DataGridView : public class CustomDataGridViewColumnHeaderCell : DataGridViewColumnHeaderCell { // adds a button to the header } A DataTable is

Custom comparer datagridview sort

一个人想着一个人 提交于 2021-02-04 16:35:27
问题 I have a datagridview with a bindingsource as datasource, and the bindingsource has a datatable as a datasource. Some columns are strings but I want them to be sorted in a specific way. The grid sorts them as 1, 10, 10,0 44a, 6c. But I want them to sorted: 1, 6c, 10, 44a, 100 as if i would take the numbers only from the values and sort them accordingly. Is there a way I cand add a custom comparer when certain columns are being sorted? Any other soulutions would be ok if the grid,

Need to set datagridview datasource with a binding source

筅森魡賤 提交于 2021-01-29 20:14:18
问题 I'm using an advanced datagridview and to use the filters that come with it you need to use a binding source. I'm writing an Oracle query (actually several of them) and using the results as a datasource. I can't seem to get it to work correctly. I have googled all the solutions and have tried them all with no success. My code: public partial class frmMain : Form { private string sql; public DataGridView DVG = new DataGridView(); public BindingSource bs = new BindingSource(); private static

How to do custom pagination on a data gridview control with custom attributes mapped to a down grid

耗尽温柔 提交于 2021-01-29 20:13:30
问题 I have a windows application where on the click of a button it fetches data from a Oracle query and when binding the gridview datasource to a datatable it takes almost 5 mins to load for 3500 records . The final gridview looks like this which is again dependent on data in the down form .on the click of any row in the first grid the second grid data should also change but now it takes huge time and seems like it is kind of doing any background task which am unable to get as am pretty new to

How to do custom pagination on a data gridview control with custom attributes mapped to a down grid

戏子无情 提交于 2021-01-29 16:38:45
问题 I have a windows application where on the click of a button it fetches data from a Oracle query and when binding the gridview datasource to a datatable it takes almost 5 mins to load for 3500 records . The final gridview looks like this which is again dependent on data in the down form .on the click of any row in the first grid the second grid data should also change but now it takes huge time and seems like it is kind of doing any background task which am unable to get as am pretty new to

Load data from SQL Server to datagridview using a thread

夙愿已清 提交于 2021-01-29 14:47:36
问题 I'm trying to load data from a SQL Server database into a DataGridView using threading with delegates and later will try to add a loading or waiting form. But I can't make it work. Dim t1 As Thread Private Delegate Sub delegate_updatedgv() Private Sub mainform_Load(sender As Object, e As EventArgs) Handles MyBase.Load t1 = New Thread(AddressOf load_dgv) t1.Start() End Sub Private Function load_dgv() Try If DBCon.State = ConnectionState.Closed Then DBCon.Open() End If DBCmd = New SqlCommand(

How to filter DataGridView to keep only a given set of rows

只谈情不闲聊 提交于 2021-01-29 11:41:21
问题 In C# I have DataGridView populated via DataSource . With some custom made filter I determine a subset of rows (by looping through the rows and checking the conditions on columns, to be precise) and need to keep/show only these rows in the DatGridView. One option I understand is to loop through the grid and hide the rows which are outside my index set. This, however, is painfully slow for larger set of rows. My question is: given a datagridview which is bind to a datasource, and a subset of

How to Merge DataGridView Cells based on same id (Column 0)

浪尽此生 提交于 2021-01-29 09:11:45
问题 I am looking to merge cells across a set number of columns where the id in column 0 is the same. An example of the DataGridView before Merged cells is: The output I am looking for is: In this example I am looking to merger cells across columns 0,1 and 2 where the Id is the same. I have been looking to utilise code found at the following Code Example but cannot get it to produce the results I require. Any assistance would be appreciated. Update I managed to get a working version but the down

Binding DataGridView to DataTable with ComboBox not working

南笙酒味 提交于 2021-01-29 04:45:21
问题 I'm trying to create a DataGridView bound to a DataTable where one column is a ComboBox. The code runs but I get the following error after binding (not when data is bound): System.ArgumentException: DataGridViewComboBoxCell value is not valid. In the DataGridView one of the columns is a DataGridViewComboBoxColumn that uses an enum (named structureType) as it's source: // ColumnStructure // this.ColumnStructure.ValueType = typeof(structureType); this.ColumnStructure.DataSource = Enum.GetValues

wrong index of checkbox column in datagrid

醉酒当歌 提交于 2021-01-29 03:09:24
问题 I have this code to add a checkbox column in the third position, but the index of this column(bloqueador) is 0 and not 3. What is wrong? public void bloqselect() { DataGridViewCheckBoxColumn chkSelect = new DataGridViewCheckBoxColumn(); chkSelect.Selected = false; chkSelect.HeaderText = "Bloqueador"; chkSelect.Name = "chkSelect"; grid_lic.Columns.Insert(3, chkSelect); if (chkSelect.Selected == true) bloqueador = 1; else bloqueador = 0; } checkbox column index 回答1: It's a quirk about the