Search Results

Search found 2511 results on 101 pages for 'datagridview trick'.

Page 10/101 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • How can I capture the keystroke that triggers "CellEndEdit" on a DataGridView in C#?

    - by Andy Stampor
    I have a DataGridView that is set to EditOnF2. I do some special processing of data in the CellEndEdit eventhandler that sets the value of the cell. I still want the functionality of the EditOnKeystrokeOrF2 of reverting to the original value when the Esc key is pressed. Unfortunately, at the CellEndEdit eventhandler, I don't see a way to tell what caused the CellEndEdit event to be fired. I only want to change the value of the cell if the Esc key is not pressed. How can I tell if it was or not? Edit: It is worth noting that the KeyDown event does not get fired when the cell is being edited, nor for the final ending keystroke. Edit2: I have tried the KeyPreview suggestion, but the form still does not capture the Escape key being pressed. Edit3: I've been experimenting with trying to get this working. I originally posted some of the following as a separate post, but feel it might be more relevant to include it here. I have a cell in a DataGridView that is now set to EditProgrammatically. To capture the keystroke that starts an edit, I am setting the cell.Value equal to the keystroke. However, this ruins the "Escape" functionality of the cell - when you press escape, instead of reverting to the original value, it reverts to the keystroke that I programmatically inserted into the cell. I believe that if I could set the "EditedFormattedValue" on a cell, this would be where I want to put my keystroke value, however this appears to be read only. How can I accomplish what I am attempting? An example to clarify: If the cell has a value of "54.3" in it, and I press the "9" key, it begins editing the cell and places a "9" there. If I hit Escape, instead of reverting to "54.3" it reverts to "9". What I want is for it to return to its original value of "54.3". So, I am trying to tackle this issue from both the beginning and the end. I think the real problem is that I am overwriting the original value and have no way to determine if I should revert it or not. Edit4: It looks like CellValidating might be worth using, but I am seeing strange behavior when I experiment with it. In a new project, I create the DataGridView and register for the various events and see that CellValidating is fired before the CellEndEdit. However, in my project where I am trying to get this to work, CellEndEdit is firing BEFORE CellValidating. Any ideas on what the difference might be?

    Read the article

  • Can I make DataGridView.EndEdit trigger the CellValidating event?

    - by Don Kirkby
    I'm using a DataGridView in my WinForms application. My main objective is to make the Enter key not move to the next row in the grid. I still want the enter key to validate and end edit mode. I found this FAQ entry and subclassed DataGridView to override ProcessDialogKey(). If the key pressed is Enter, I call EndEdit(), otherwise I call base.ProcessDialogKey(). It works great, except the CellValidating event isn't fired. Currently, I'm just manually calling my validation logic before I call EndEdit, but it seems like I'm missing something. I guess I could call OnCellValidating, but then I'd be worried I'm missing some other event. What I really want is some flavour of EndEdit() that behaves just like pressing enter on the last row of a grid with adding disabled.

    Read the article

  • Is it possible to manipulate the format on a DataGridView that is bound to a Data Source?

    - by Jack Johnstone
    I´m using SQL Server 2005 and Visual Studio 2008, C#. In the data source (the SQL Server data table) I use the date format mm/dd/yyyy, however, in a forms overview (DataGridView) users would like to see a completely other format, with year, week number and day number of week (yyww,d). I´ve created an algorithm for this transformation, but can I populate the affected cells with yyww,d instead of mm/dd/yyyy? And in that case - how would I do it? I guess I need to do it after the cells are populated, but before they are shown. The generic question is - how do I manipulate the format of Data Source bound DataGridView cells.

    Read the article

  • In a Windows forms application, how can I use a listbox in a DataGridView coloumn instead of a combo

    - by Alex
    I'm working on a windows forms application that uses a DataGridView. Some of the cells contain a DataGridViewComboBox. In some cases, I have several values to display in the combobox. For that scenario, it would be better to use a ListBox instead of a ComboBox. Is it possible to use a multi-column listbox within a DataGridView instead of a ComboBox? If so, can you point me in the right direction? Thanks much. Al D.

    Read the article

  • For a DataGridView, how do I get the values from each row?

    - by David L
    I am wondering what is the best way to go iterate through all the rows in a datagridview and get the values from the cells. Here is what I am thinking of doing, but I don't really like it because if I rearrange the columns then the code will also have to be changed. for (int i = 0; i < dataGridView.RowCount; i++) { string Value0 = dataGridView1.Rows[i].Cells[0]; string Value1 = dataGridView1.Rows[i].Cells[1]; string Value2 = dataGridView1.Rows[i].Cells[2]; }

    Read the article

  • Exception when click DataGridview tab c#, .Net 4.0

    - by Nguyen Nam
    My winform app have two tab and multi thread, one is main tab and other is log tab. I only use log tab to show logs in a datagridview control. Exception is random occurred when click to log tab (Not click to row or colunm), i have try but can not find anyway to fix it. This is the error log: Message : Object reference not set to an instance of an object. Source : System.Windows.Forms TargetSite : System.Windows.Forms.DataGridViewElementStates GetRowState(Int32) StackTrace : at System.Windows.Forms.DataGridViewRowCollection.GetRowState(Int32 rowIndex) at System.Windows.Forms.DataGridView.ComputeHeightOfFittingTrailingScrollingRows(Int32 totalVisibleFrozenHeight) at System.Windows.Forms.DataGridView.GetOutOfBoundCorrectedHitTestInfo(HitTestInfo& hti, Int32& mouseX, Int32& mouseY, Int32& xOffset, Int32& yOffset) at System.Windows.Forms.DataGridView.OnMouseMove(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseMove(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.DataGridView.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) Message : Object reference not set to an instance of an object. Source : System.Windows.Forms TargetSite : Void ClearInternal(Boolean) StackTrace : at System.Windows.Forms.DataGridViewRowCollection.ClearInternal(Boolean recreateNewRow) at System.Windows.Forms.DataGridView.OnClearingColumns() at System.Windows.Forms.DataGridViewColumnCollection.Clear() at System.Windows.Forms.DataGridView.Dispose(Boolean disposing) at System.ComponentModel.Component.Dispose() at System.Windows.Forms.Control.Dispose(Boolean disposing) at System.ComponentModel.Component.Dispose() at System.Windows.Forms.Control.Dispose(Boolean disposing) at System.Windows.Forms.TabControl.Dispose(Boolean disposing) at System.ComponentModel.Component.Dispose() at System.Windows.Forms.Control.Dispose(Boolean disposing) at System.Windows.Forms.Form.Dispose(Boolean disposing) Update status code: private void updateMessage(int index, string message) { try { this.dgForums.Rows[index].Cells["ColStatus"].Value = message; System.Windows.Forms.Application.DoEvents(); } catch { } }

    Read the article

  • Trick XP into having more RAM?

    - by Industrial
    Hi everyone, Are there any way known to trick an computer with XP to appear to have more RAM? I need to install a specific program (which fits in my system requirements), which is bundled with a number of other programs on an DVD. Unfortunately, the other programs besides the one that I need demand twice the amount of RAM that's available on my computer and the installation is closed due to this. Can I trick my XP computer into have more RAM temporarily to bypass the block in the install executable? Thanks

    Read the article

  • Does a custom DataGridView Cell have to have a parameterless constructor?

    - by clawson
    I want to slight variation of the custom cell code example from the MS website How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance by passing an argument to the custom cell constructor. Public Sub New(ByVal a As Object) End Sub but then when I run the code it throws and exception MissingMethodException occured No parameterless constructor defined for this object. Does this mean that custom cells must have a parameterless constructor? Thanks.

    Read the article

  • How can I remove the current cell focus from A Windows Forms datagridview ?

    - by Kottan
    How can I remove the current cell focus from a Windows Forms datagridview ? I have a dialog with some datagridforms and initially I don't want to have a cell selection. Actually in every gridview the cell [1,1] is selected I have already searched in some forums, but the provided solutions doesn't work. For example often it is recommended to set CurrentCell = null -- but this has no effect. Has anybody another solution, which really works ;-) ?

    Read the article

  • How to use another type of EditingControl in a single C# 3.5 DataGridView column ?

    - by too
    Is this possible to have two (or more) different kinds of cells to be displayed interchangeably in single column of C# .Net 3.5 DataGridView? I know one column has specified single EditingControl type, yet I think grid is flexible enough to do some tricks, I may think of only: Adding as many invisible columns to grid as required types of cells and on CellBeginEdit somehow exchange current cell with other column's cell Create custom column and custom cell with possibility of changing EditingControl for single cell Which approach is better, are there any examples ?

    Read the article

  • How to display data into datagridview using multi thread?

    - by Mark
    Hi, I have application where I read/receive data all the time (text) and I need to display this data into datagridview, what is the best way to do that in real time, so the data will be changed all the time. I thought about multi threading, if this is a good idea can you guide me with link to explain how to implement it. Thanks

    Read the article

  • How to use another type of EditingControl in a single .NET 3.5 DataGridView column ?

    - by too
    Is this possible to have two (or more) different kinds of cells to be displayed interchangeably in single column of C# .Net 3.5 WinForms DataGridView? I know one column has specified single EditingControl type, yet I think grid is flexible enough to do some tricks, I may think of only: Adding as many invisible columns to grid as required types of cells and on CellBeginEdit somehow exchange current cell with other column's cell Creating custom column and custom cell with possibility of changing EditingControl for single cell Which approach is better, is there any other solution, are there any examples ?

    Read the article

  • .Net DataGridView "Index 0 does not have a value."

    - by Ben
    I am having trouble with a DataGridView. I have a collection of 3 Items bound to the grid, when trying to delete one of the items and reload the grid. If have code of If (dlg.ShowDialog() = DialogResult.OK) Then 'Show dialog with grid on it End If On the opened dialog, I delete an item from the grid (which should in turn, delete the item from the collection, and re-load the grid), and it returns to the "If (dlg.show..." line, with the error of "A first chance exception of type 'System.IndexOutOfRangeException' occurred in System.Windows.Forms.dll Additional information: Index 2 does not have a value. " (I have break into debugger set on for common language runtime errors) I can understand this error if i were trying to access any cells, row or columns, but im not, and then I would expect the exception to stop on the line of code that is trying to access this grid data, not the "If (dlg.ShowDialog()... " line Any ideas? Cheers

    Read the article

  • DataGridView selectedRow Property not get Data if i double click Row?

    - by programmerist
    i click double dataGridView's any row. Not get Data clicked row data: private void gwStudies_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { GoruntuyuAc(); } private void GoruntuyuAc() { olduid = ""; DataRowView ro = (gwStudies.SelectedRows[0].DataBoundItem as DataRowView); string uid = ""; uid = ro["StudyInstanceUid"].ToString(); string tarih = ""; DateTime t1 = Convert.ToDateTime(ro["StudyDate"]); //........ //............ } Error Data on (gwStudies.SelectedRows[0].DataBoundItem as DataRowView); IMAGE:

    Read the article

  • Locked DataGridView. Linq is a problem ?

    - by phenevo
    Hi, I get the collection from webservice: var allPlaceHolders = (from ph in new MyService().GetPlaceHolders() select ph).Select(l => new { Code = l.Code, Name = l.Name, Related = false }).ToList(); dgPlaceHoldersAdd.DataSource = allPlaceHolders; Designer.cs: this.dgPlaceHoldersAdd.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgPlaceHoldersAdd.Location = new System.Drawing.Point(3, 54); this.dgPlaceHoldersAdd.Name = "dgPlaceHoldersAdd"; this.dgPlaceHoldersAdd.RowHeadersVisible = false; this.dgPlaceHoldersAdd.Size = new System.Drawing.Size(286, 151); this.dgPlaceHoldersAdd.TabIndex = 15; The problem is, that I can't changing value of checkBox column. I has enabled AutoGeneratedColumns (In datagridview at start there is not any column)

    Read the article

  • How do I mimic Windows Explorer multi-select/drag-n-drop behavior in a DataGridView?

    - by bsh152s
    I'm trying to mimic the way Windows Explorer handles multiple selection. In a default DataGridView, you can select multiple items using Ctrl-click. But if you release the Ctrl key and then try and drag/drop the selected items, it clears the selected items and only selects the "hit" row. I found the following solution somewhere online. protected override OnMouseDown(MouseEventArgs e) { int hitRowIndex = HitTest(e.X, e.Y).RowIndex; if(!SelectedRows.Contains(Rows[hitRowIndex])) { base.OnMouseDown(); } } However, this causes other side effects. With the CTRL key pressed and mousing down on a selected item, the item remains selected. This makes sense because the mousedown event is bypassed if the row clicked on is selected. From looking at the behavior of Windows Explorer, it looks like the deselection of an item with the CTRL key held is not handled until the MouseUp event. Has anyone tried to do this?

    Read the article

  • How can I receive the "scroll box" type scroll events from a DataGridView?

    - by Simon
    I have a DataGridView, and I'm listening to its Scroll event. This gives me a ScrollEventArgs object whose Type member is supposed to tell me the type of scroll event that has occurred. On the MSDN documentation page it says I should be able to detect movement of the scroll box by listening for events with types ThumbPosition, ThumbTrack, First, Last and EndScroll. However, when I drag the scroll box, I only get events of type LargeDecrement and LargeIncrement. How do I get access to the ThumbPosition, ThumbTrack, First, Last and EndScroll events?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >