.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan
Post New Web Links

Dev Q&A: DataGridView

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net
 

After receiving a late-breaking news bulletin at magazine headquarters early this month stating that the Web is just a fad that will never amount to anything, we have reluctantly decided to retire our venerable Web Q&A column and replace it with one we like to call Dev Q&A.

Edited by Nancy Michell

MSDN Magazine January 2006




View Complete Post


More Related Resource Links

Custom Editing Behavior for DataGridView TextBox Columns

  
For various reasons I'm using a DataGridView instead of a ListView, and while configuring the DataGridView to look like a ListView wasn't much of a problem, there's one thing that got on my nerves, which is the behavior of textbox cells in edit mode: It is much too easy to leave the edit mode accidentally, simply by pressing the cursor keys at the wrong time. For example when the text caret is positioned behind the last character of the textbox cell content, and you press the right arrow key

AutoCompleteStringCollection for text box in DataGridView 2.0

  
I have been searching for a way to have autocomplete in a DataGridTextBox
object. There does not appear to be an obvious way to do this like you would
for a TextBox outside of a grid using the AutoCompleteCustomSource. Any
thoughts on how I can add this collection? :)

datagridview row selection and coloring.

  
HI !I am a novice in C#.net. I have a datagridview on my form. I want to change the row color by rolling over the mouse on the row not by clicking on the row and when mouse mouse leave the row then the row color is back to the original color. I want to know that which event should i use?any help would be appriciated.

Text in Datagridview-Zelle unterschiedlich einfärben

  
Hallo zusammen, wie kann ich einen Text in einer Zelle unterschiedlich einfärben ? Wenn in der Zelle z.B."4711/ART" steht, dann möchte ich "ART" rot einfärben. Es geht also darum, einen Teil des Zellinhaltes farblich hervor zu heben. Gruß jogi

distinct datagridview

  
how can i select distcint from datagridview

DataGridView>Edit Columns> Column Read Only property is unwilling to change

  
Hello, I am facing the following mystery: When changing the read only property of a column to false and reopening the "edit columns" window, it mysteriously turns back to true. Even when closing the designer and changing it in the designer code, the resulting execution does not allow edit, as well as when re-opening the designer you see true again.             this.numberDataGridViewTextBoxColumn1.DataPropertyName = "Number";             this.numberDataGridViewTextBoxColumn1.HeaderText = "Number";             this.numberDataGridViewTextBoxColumn1.Name = "numberDataGridViewTextBoxColumn1";             this.numberDataGridViewTextBoxColumn1.ReadOnly = true;//False is required We thought it might be related to data binding. rebinding the grid did not help as well. The is no other place in the code where it changes. Please advice, Thanks

Moving Datarow from datagridview to textboxes

  
Hi , I need to know how to copy a datarow from datagridview to subsequent textboxes.I have three textboxes and three fields in datagridview .

wpf datagridview checkbox column selection not working fine.

  
Hi Experts,in my c#.net windows based wpf application i added  a datagridview.dynamically i added checkboxcolumn to that datagridview DataGridViewCheckBoxColumn cbCol = new DataGridViewCheckBoxColumn(); GridSource.Columns.Add(cbCol); and another column is string. to this column am hardcoding the values DataTable _datatable = new DataTable(); _datatable.Columns.Add("Name", typeof(string)); _datatable.Rows.Add("CSRs"); _datatable.Rows.Add("Customers"); GridSource.DataSource = _datatable; till here fine am getting two columns (checkbox and Name)when i am trying to check those checkboxes problem comming.am trying to get the count of the checked rows for that i used below code int cbcount = 0; foreach (DataGridViewRow _dgRow in GridSource.Rows) { if ((bool)_dgRow.Cells[0].Value) cbcount++; } cbcount will give the checked count.but the problem raising here if i check 2 rows it giving 1if i check 5 rows it giving 4if i check 1 row it giving me 0means am getting n-1 resultwhere i did wrong??

Sending 'ctrl-c' to the datagridview row of an external application using win32 api. Please help.

  
I'm just not able to send ctrl-c using my C# application to an external WinForm application. Here is my sequence of commands. I compared the messages using Spy++, and it matches except for my SendMessages are showing up as Send and Receive, vs. the same operation done on the WinForm is showing up as posted. My command sequence : NativeMethods.SendMessage(hwnd, WM_KEYDOWN, 0x00000011, 0x001D0001); NativeMethods.SendMessage(hwnd, WM_KEYDOWN, 0x00000043, 0x002E0001); NativeMethods.SendMessage(hwnd, WM_CHAR, 0x00000003, 0x002E0001); NativeMethods.SendMessage(hwnd, WM_KEYUP, 0x00000043, 0xC02E0001); NativeMethods.SendMessage(hwnd, WM_KEYUP, 0x00000011, 0xC01D0001); My Spy++ sequence : <00001> 0059043C S WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:299 yPos:52 [wParam:00000001 lParam:0034012B] <00002> 0059043C R WM_LBUTTONDOWN <00003> 0059043C S WM_LBUTTONUP fwKeys:MK_LBUTTON xPos:299 yPos:52 [wParam:00000001 lParam:0034012B] <00004> 0059043C R WM_LBUTTONUP <00005> 0059043C S WM_KEYDOWN nVirtKey:VK_CONTROL cRepeat:1 ScanCode:1D fExtended:0 fAltDown:0 fRepeat:0 fUp:0 [wParam:00000011 lParam:001D0001] <00006> 0059043C R WM_KEYDOWN <00007> 0059043C S WM_KEYDOWN nVirtKey:'C' cRepeat:1 ScanCode:2E fExtended:0 fAltDown:0 fRepeat:0 fUp:0 [wParam:00000043 lParam:002E0001] <00008> 0059043C R WM_KEYDOWN <00009> 00590

Combobox in DataGridView

  
Hi, How do I setup a selected value for a combobox column in datagridview? Unlike a regular combobox I can't use: SelectedValue = 1; I'll give an example :Let's say I have a datagrid which is consisted of two datasets tables: one table which contains 300 entries for different types of cars, and a combobox column which contains a list of 10 car makers (that's the second table). The car maker's code is the primary key in the combobox column's value member and the foreign key in the first table. How do I load the datagrid so that t the combobox will display the correct car maker for every car entry (300 in total)? here's my current code: private void SetupDataGridView() { this.Controls.Add(carsGrid); DataGridViewComboBoxColumn comboGrid = new DataGridViewComboBoxColumn(); carsGrid.DataSource = dsCars.Tables[1]; carsGrid.DisplayMember = "CarMakerName"; carsGrid.ValueMember = "CarMakerID"; carsGrid.DataSource = dsCars.Tables[0]; carsGrid.Columns.Add(comboGrid); } Thanks, Udi

DataGridView - Speeding setting Visibile on many rows.

  
I have to set the visibility of many rows on a DataGridView. Even though there is only about 6000 it takes a very long time. I used temporary datasources to hide the rows but this makes an object not be associated with a row any more (and so for this situation is not acceptable). Is there any functionality for multiple updates to the DataGridView like the behaviour for the ListView which had the BeginUpdate and EndUpdate on it?

DataGridView freeze columns issue

  
When i try to freeze a column that is off screen (to the right) when the DataGridView's (DGV) first displayed column is the first column in the DGV, the DGV refreshes and displays the DGV from the first column in the DGV. Also, the horizontal scrollbar on the bottom of the page disappears.  This means that i cannot see the unfrozen columns and i cant get over to view the column that I froze. This seems to behave differently from freezing a column in Excel, which freezes the columns you are currently viewing at that moment (not sending you back to the first row) and then the scroll bar applies to the frozen columns like normal. Is there a workaround for this? I tried setting the first displayed index for the column and I get an exception. I'm using .NET 3.5 on an XP machine.

Most efficient way to check whether a DataGridView contains some specific text at a specific column

  
Dear All,   I am looking at the most efficient way to check whether a specific column of a DataGridView contains some text. For example I have a list of firs names and I would like to check whether the text "Bob" already exists in that columns. I would like to avoid to loop through each row but what thinking of using something with "Contains".   Anybody has an idea ?   Cheers,   Kalos

Struggling to remove ellipses when columns in a DataGridView are automatically truncated

  
Hi all, I've got approx. 20 columns in a DataGridView so screen real estate is a little limited! All the columns have a fixed width, and in my old DataGrid when the content was too big for cell it would simply disappear off the edge so a cell containing 'flibberty' would be in the table cell |flibber| In contrast, with datagridview this becomes |flibb...| - I'd really really like to get rid of these ellipses and get the old DataGrid behaviour for this case - but it doesn't seem straightforward at all, can anyone help? Thanks, Henri

Datagridview painting "EXTREMELY SLOW" on new PC

  
Hi, I have a appliation I wrote in .net 2.0 (VS 2005) and on all PCs except one it runs great, but on this one laptop (a brand new Dell XPS 1530) the Datagridview paints so slow when scrolling or resizing that you can see each row paint as if in slow motion.  It's so bad I would be extremely hesitant to relase the application as I know someone would complain.   Has anyone else seen this issue?  It's only happening on certain PCs.  The PCs in question are all up to date via windows update, so they have the same versions of everything.  The laptop has a Nvidia 8600GT chip in it with the latest drivers and I actually have the same drivers on some of the PCs where the grid is fast.   Thanks,   Tony Caduto AM Software Design Home of Lightning Admin for PostgreSQL and MySQL http://www.amsoftwaredesign.com

DataGridView Formatting

  
Hey, I have couple of questions about DataGridview, 1.How do I format the datagridview not to show the first column (which looks like button with arrow in it)? 2. How to hide the value in a cell if previous row cell has same value it (if it matches)? Thanks

Reconhecer checkBox dentro de DataGridView em Windows Form com um evento checkedChange...

  
Então ... eu to com um grid e dentro tenho o checkBox... quando a pessoa selecionar ele vai deixar a linha amarela... quando tirar a seleção ele muda a linha... e caso fique selecionado ao apertar um botao de insert... o sistema vai cadastrar o que esta selecionado... mas nao consigo pegar os valores dentro do grid...
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend