datagridview

How to bind dataGridView predefined columns with columns from sql statement (without adding new columns)?

Hey, Is there a elegant way, to bind predefined dataGridView columns with results from sql statement? Example: dataGridView1.Columns.Add("EID", "ID"); dataGridView1.Columns.Add("FName", "FirstName"); some sql like SELECT t.FirstName as FName, t.EmpID as EID FROM table t ... and then I call dataGridView1.DataSource = someDataSet.Tab...

Saving nested XML in C#

I've go the following XML file... <A> <B> <C>ValueX</C> <D>ValueY</D> </B> </A> Which I read into a DataSet to display it in a DataGridView. DataSet ds = new DataSet(); DataTable t = new DataTable("B"); ds.Tables.Add(t); t.Columns.Add("C", typeof(string)); t.Columns.Add("D", typeof(string)); // bind to DataGridView ds.Rea...

C# Update and Delete row table using tableAdapter, mdb access, dataGridView

I have a DataGridView, which loads data from mdb Access table The grid only shows data (is readonly). I have a button for inserting new row, and now have to make two more buttons, one for update and one for delete The following code works fine for inserting a new row this.estacionamientoTableAdapter.Insert(tb1.Text, tb2.Text, tb3.Tex...

set tag in DataGridViewRow from DataTable automatically

Is there a way to use a column of data from a DataTable to set the tag of a row automatically instead of having to iterate through each row in the DGV to manually assign it? MyDataGridView.DataSource = GetDataTable(); foreach (DataGridViewRow dgvr in MyDataGridView.Rows) { dgvr.Tag = (int)dgvr.Cells[0].Value; } I have a large amount ...

Unbound DataGridView issue

I am able to write to my unbound datagridview (VC++), but am unable to read back that same exact value. So I can do this: myDataGridView[0,0]->Value = 1 ; And this updates my display correctly. But I can't do this: printf("value=%d\n", myDataGridView[0,0]->Value ; It compiles, but regardless of which cell I read, and regardless i...

How do I specify what the column type a DataGridView chooses to use when using DataTable as its DataSource

I have a column in my DGV that is a custom type to display values of MyObjectType. My DataTable has the column created as MyObjectType, but the DGV creates a DataGridViewTextBox column and populates it with MyObjectType.ToString(); which is not the behavior I want. Can I either force the data to be loaded into preexisting columns; or...

Horizontal scrolling in Datagridview

Hi all, I want to scroll horizontal in my grid (inherited from DataGridView). Not with Ctrl+scrolling tiltwheel (mousewheel), but by pushing the mousewheel to the left or the right. First I tried it by catching the WM_MOUSEHWHEEL (0x020E) message in WndProc, but this fires only once (and I want to keep on moving left or right as long a...

Populating a DataGridView on-the-fly (VB.NET)

Hi all, I have a DataGridView which reads data from a custom (CSLA) list object. The dataset might have 100,000 records, and obviously I don't want to show them all at once because, for one, it would take ages to load. I think it would be nice if I could read the first (for instance) 20 records, and make it so upon scrolling to the end...

Disable Cell Highlighting in a datagridview

How to disable Cell Highlighting in a datagridview, Highlighting should not happen even if I click on the cell. Any thoughts please ...

DataGridView / Enter Key ?

I'm using vb.net 2008 and DataGridView. I'm looking for code that will allow me to have the Enter key move to the next column to the right instead of moving down one row while remaining in the same column. ...

Convert Custom Object To DataRowView C# WinForms

I have a custom object as follows public partial class _AccessionType { private string accessionIdField; private string docUrlField; /// public string AccessionId { get { return this.accessionIdField; } set { ...

Getting blank rows after setting DataGridView.DataSource. How to solve this problem?

Hello, Could somebody tell me why I'm getting blank rows after runnign this code?? ... dataGridView.AutoGenerateColumns = false; //must be false, else getting additional coulumns from sql. dataGridView.DataSource = dataSet.Tables[0].DefaultView; Also tried dataGridView.Update(); but not working. Row count is ok, but why blank ro...

DataGridView: Pass by Value or Reference?

I think of DataGridView's as being memory hogs. Is it better to pass by value a datagridview or by reference? Should it even be passed at all? ...

Preserve DataGridViewRow.Tag property in databound DGV when sorting data

Is there a way to keep the tags from being nulled as soon as I sort the grid? If not, is the Tag property actually useful for anything except non-databound usage? ...

vb.net dataTable/DataGridView search/sort

So I have a dataGridView and a textbox on a form. I want to be able to search through the dataGridView and sort it compared to the string in the text box. ex: I type "acv" in the text box and all strings containing "acv" are sorted to the top. I'm accomplishing this with a bunch of gymnastics involving datatable.select and some clearin...

WPF DataGrid CellEditingTemplate with floating control

Hello, I'm using the WPF DataGrid and want to make my own CellEditingTemplate. I want to replicate something like the DatePicker that doesn't replace the whole contents of the cell when its being edited, but instead just floats Like this: http://i3.windowsclient.net/SiteFiles/1000/wpfsp1/wpf-35sp1-toolkit/107-2.png?cdn_id={b4d0570c} I t...

Sorting a DataGridView by Number or Date in a Windows Form C#

I have a DataGridView on a C# Forms Application I'm trying to sort. Originally I wanted to sort by the date, but when sorting it treats it like a string. Example: 22/9/2009 14/4/2008 3/12/2007 Sorts to 14/4/2008 22/9/2009 3/12/2007 Because its only looking at the first character. Once I couldnt solve this I tried to sort by an ID co...

How to switch between DataGridViewTextBoxCell and DataGridViewComboBoxCell?

I want to have a DataGridView that has two columns. The first column will always be of type DataGridViewComboBoxColumn. Based on the selection in that column, I'd like to be able to change the corresponding cell in the second column to either a DataGridViewComboBoxCell or a DataGridViewTextBoxCell. I'm thinking I just need to make the...

Implementing Mask property to display data in DataGridView Winforms control

I'm aware of articles and examples about using MaskedTextBox for editing data in a DataGridView control, i.e. DataGridViewCustomColumn DataGridViewMaskedText GenericDataGridView etc. What I need is to display string values (like telephone numbers, SSN...) with a given Mask in DataGridView control. I'd like to set Mask property for a...

WPF - datagridview options

Hi all, Need to represent a two column table. Maybe just for reference at this stage - or with the functionality that a double click presents a combobox essentially on that field with all the possible values that can be entered. Is datagridview the best option for this in WPF or what else could I do to represent the data? Cheers, ...