datagridview

Am getting un-expected NULL values in a Datagridview's calculated column

I have a Bindingsource that am setting as a datasource to a DataGridView control. In its dataset query i have a calculated column(Column1). When i go to the Bindingsource's tasks and click Preview Data i can, for my Column1 other rows have data values returned and for other rows NULL is returned which is ok and expected. The problem is ...

DataGridView and checkboxes re-selecting automatically

I have a strange problem with a DataGridView I'm using which is bound to a table in VB.net I've added a checkbox column to allow a user to tick a bunch of rows that I can then loop through and save off to a different table. All the checkboxes are enabled by default. So it's really a case of unchecking the rows which aren't required. Ho...

Rearranged columns in C#

How can I get the rearranged columns out of a datagridview in C#? I need to get all the columns currently being displayed in order. I can get the default columns order by setting datagridview.AutoGenerateColumns=false but I get the same old order even after I've rearranged the columns in my table. Edit: Basically what I need is to be ab...

how to retain exact numbers that come from Access Database

MY scenario is... I have 6,000 datas in Excel Sheet.. I try to import to Access Database.It enters the Database like this.. UNit Price 34512.00 Vat 4.00 BUt when i Retrieve to DataGridColumn it Shows vat Rate as 4(whole number).I accept zeros has no values..But I need that to be displayed in Grid as 4.0 . How to achieve this ...

How to calculate unbound column value based on value of bound colum in DatagGridView?

Hi. I have few columns in my DataGridView, one of them is an unbound column and the DataGridVIew is in VirtualMode. When CellValueNeeded event is called, I want to calculate value of Cells[0] basing on the value of Cells[2] which is in bounded column to the underlaying DataSource. This is how I try to do this: private void dgvItems_C...

Center current record in DataGridView

When programmatically changing the current record in the DataGridView is it possible to make it in such way that this record would be centered (vertically) in the grid? When I change the current record it is shown either as the top row or as the bottom row. I'd like it to be in the middle. Would this be possible/simpler in WPF? ...

When you bind list<> to datagrid - how to cahnge column names ?

I have a code: VideoChannel[] channels = GetVideoChannels(); dataGridView1.DataSource = channels; dataGridView1.Refresh(); VideoChannel is a class with many properties. This code works OK, but I want to change column names. By default, column name = property name of VideoChannel. Is there some attribute that I can mark a property of ...

Prevent some DataColumns in a DataTable from being bound to DataGridView

Is there any way I can specify that some columns in a DataTable will not be automatically bound to a DataGridView when I set the DataSource property of the DataGridView to the DataTable. For example, if I have a DataTable with columns as "Id, Name" then can I specify that Id column will not be shown in DataGridView? I know I can set som...

dataGridView handle seperatordoubleClick when overloading the paint event hand enlarging the column

I have a dataGridView which one of it's columns has an image with text. When double clicking on the column separator, width matches text width minus the image width- i.e. column is not expanded as needed. What is the way to handle this? ...

how to use fillWeight property and yet enable horizontal scrolling

I have a few columns in a dataGridView want them to fill the space. column A has a fixed width column B can be long and scrolling should be possible column C is fixed- unresizeable, and minimum width is set. what is the way to use these property for achieving the desired behavior ...

Combobox in bound DataGridView

Hi. I've got a DataGridView control which is bound to a database table. I want one of the columns in the gridview to be of combobox type. The combobox should contain a list of hardcoded strings, which is the same for all rows in the datagridview. One of the fields in my database table is an index for this list of hardcoded strings. ...

DGV Column/CellStyle.format not working

I wanted the user to input values in "dd MMM yyyy" format Only, I'm using dataGridView1.Columns["Rel_Date"].DefaultCellStyle.Format = "dd MMM yyyy"; in Form_Load......... But somehow it's not working. ...

Updating DataGridView from another Form using BackGroundWorker

Hi! I Have one Form (LoginForm) which has a Background Worker Monitoring a database for new entries. Then I have another Form (AdminForm) which I need to signal to update its datagrids whenever new data is available. I could poll the database in the AdminForm too, but considering that LoginForm is already doing some polling, which can...

C# - Saving a DataGridView to file and loading

Hello, To start off, what I have is a simple Winforms app, with just a save and load button, and with a datagridview control to hold data. What I am looking to do is input some data into the control, hit the save button, and it save all the data to a file locally on the computer, and when I hit load, it loads the file and populates the ...

Datagridview DateTime Format not using System Region settings

I've got a datagridview that is hooked up to a bindingsource on my main form. One of the columns and datamembers in the bindingsource is a DateTime object. When the datagridview shows this item it doesn't use Window's default region settings for displaying datetime. The weird thing is, I can access this same DateTime object and print ...

Replacing cells in DataGridViewComboBoxColumn()

In my DataGridViewComboBoxColumn, I want to replace null value cells with DataGridViewTextBoxCell cells that basically say "this cell cannot be changed". The following code does this exactly the way I want: foreach (DataGridViewRow row in dgv.Rows) { if (row.Cells[9].Value == DBNull.Value) { DataGridViewTextBoxCell cell...

How can I add array data in winform datagridview?

I generated Personel[] type array from Biz.Bal.GetPersonelById("1") but if I want to add winforms, I do that like below. Is there a simpler method? Like GridView.dataSource=myArray? private void Form1_Load(object sender, EventArgs e) { Form_init(); Model.Personel[] list = new Model.Personel[0]; ...

what's the DataGridView cell event changed programmatically

Hi All, I have a DataGridView in a Windows Forms Appliation, The grid bound with a data table, what's the DataGridView event which occurs when changing a cell's value in the data table and the changes reflects to the DataGrid. thanks in advance ...

c# bound Datagridview

I have a datagridview and it is bound to a stored procedure which returns a number of result columns. There is also a binding navigator with "Add New" button included. If I click "Add New" button, it creates a new row in datagridview automatically, and If I leave that new row by clicking a different row. datagridview invokes "commit"...

DataGridView: how to make scrollbar in sync with current cell selection?

I have a windows application with DataGridView as data presentation. Every 2 minutes, the grid will be refreshed with new data. In order to keep the scroll bar in sync with the new data added, I have to reset its ScrollBars: dbv.Rows.Clear(); // clear rows SCrollBars sc = dbv.ScrollBars; dbv.ScrollBars = ScrollBars.None; // continue to ...