FAQ Database Discussion Community


DataGridView anchors

c#,datagridview,anchor,windows-forms-designer
I have a Windows Form with 2 DatagridViews placed side by side, but when I maximise the form they either remain with their original sizes or one overlaps another, depending on how I've set the anchors. Is there a way I can limit how much those controls can grow to...

Gridview row count with condition [closed]

c#,winforms,datagridview
I have a gridview which is bounded with a combobox and when an item in the combobox is selected the gridview shows the data. I want to know the number of male and female from gridview in 2 labels but I couldn't find a good solution please give me tips...

RowLeave event called when DataGridView loads

vb.net,datagridview,row
I am using a datagridview to populate an Access Database to a form in VB.net. I want to perform certain actions (validation/updating database) when a user changes values in a row. I want to wait until the row loses focus to perform the changes. I am using the RowLeave event...

Image Displaying a Red “X” in a DataGridView when loading from Resources

c#,image,datagridview
Im Trying to add a Image column From My Project's Resources to a newly created DataGridView This Is the Code: DataGridViewImageColumn myImage = new DataGridViewImageColumn(); myImage.Image = Properties.Resources.bullet_arrow_down; myImage.ImageLayout = DataGridViewImageCellLayout.Zoom; myImage.Name = "Remove"; DirectoryGrid.Columns.Add(myImage); But When i run the code i get the default "X" Image and not my...

Populate DataGridView Column With a Double forcing to 2 Decimal Places, with Sort

vb.net,sorting,datagridview,formatting
Sorry for the weird title but I didn't know how to phrase it any better. I'm trying to populate a column on my DataGridView with a number that has 2 decimal places. To do this I'm using Dim _Size as Double = 1.2345 DataGridView1.Item(0, 0).Value = Format(_Size, "0.00") This populates...

Get DatagridviewComboBoxCell's SelectedIndex

c#,winforms,datagridview,datagridcomboboxcolumn
I have a Winforms application which has a DataGridView. The DataGridView is not bound to a datasource. I'm reading a text file and according to each line in the file, I'm placing the values of each row to the datagrid. I have a column in my grid that is a...

Datagridview doesnt auto select first row after filling datasource

vb.net,visual-studio-2010,data-binding,datagridview
i have datagridview with 4 columns [Nam] , [ID] , [Shuru] , [Payan] second column ([ID]) is hidden and is used to gather some details about the data. this is the Load code : Private Sub SalMali_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.DGV_SalMaliTableAdapter.Fill(Me.FDBDataSet.DGV_SalMali) End Sub which...

Displaying data from a DataGridView on one Form into TextBoxes on another

c#,winforms,datagridview
I have two forms. ShoppingBasketForm.cs and EditBasketPopup.cs. ShoppingBasketForm.cs displays a shopping basket in a DataGridView called dataGridBasket which is bound to a seperate List<OrderItem>OrderItems which comes from my OrderItemclass. This can be added to by filling in the provided text boxes/numericUpDowns on the page Product Name Quantity and LatestPrice and...

Entity Framework Datagridview delete strange behaviour

c#,winforms,entity-framework,datagridview
In a Windows Forms MDI Application .net 4.0 with Entity Framework 4.4 I have the following strange behaviour: In a MDI-Child-Form is a datagridview databinding: private void DGUser_gridBind() { _users = _frmmaster.DataAdmin.RepositoryAdmin.GetAll<User>(); DGUser.DataSource = _users; } The binding is using the context of the master form. I want that the...

Get Selected index and Selected item from DataGridViewComboBoxCell in unbound column

c#,.net,winforms,datagridview
I have a big problem that make me so confuse that I have a DataGridView without using binding which has DataGridViewComboBoxColumn (unbound column) and I want to get selected index or selected item in the ComBoBoxCell (my item i custom item). I try to cast or follow this website (http://satishjdotnet.blogspot.com/2009/05/getting-selected-value-of-combo-box-in.html)...

Receiving error “no database selected” when trying to query DB [closed]

c#,mysql,datagridview
i'm a student in a vocational high school and i'm still new to programming, i have an assignment to create a application using c#, and i have a problem in joining 3 tables to display on datagridview.. i have tried the query on mySql it works just fine, but when...

Draw image in the DataGridView header by text's side

c#,image,winforms,datagridview
I'm trying to draw an image in the DataGridView header by text's side. I can draw the imagem but it loss resolution. Why? before: after (on the DataGridView header): I tried to resize it but it doesn't make difference. Also, I want to keep the header's text and place the...

Newtonsoft Json Deserlize as C# Datagridview

c#,json,datagridview,json.net
I have some issues using the Newtonsoft Json Plugin. I want to fill a datagridview using Json but dont know how. In the Documentation of Newtonsoft Json i get an exmaple with datatable but if i try this sample i just get Errors. This is my Json: [ { "id":...

Inserting all the rows in a List View to a Data Grid View

vb.net,listview,datagridview
I have a ListView that has several items. I want to pass the items to a DataGridView but I keep getting this error: An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in System.Windows.Forms.dll Additional information: InvalidArgument=Value of '14' is not valid for 'index'. This is the code I use: Dim num...

DataGridView value doesn't change when calling CellContentClicked event

c#,datagridview
My expectation: Is Wash and Is Return are ComboBox columns; when I click Is Wash, I intend to change Is Return to true. This is my DataGridView: I tried to use CellContentClick and CellClick Below is my function: private void dtGridViewLoan_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) return;...

Search for a column in database table and add the values to a datagridview

database,vb.net,datagridview
I want to search for the value where item = 'apple' and then add the entire column to a DataGridView in VB.net form application. I use following code lines to do my task, but the output i get is a blank data cell. Dim table As DataTable = myTable.Tables("fruits") Dim...

How to get value from dataGridView which is imported from .xls file

asp.net,vb.net,gridview,datagridview
I have an application that allow me to import .xls/.xlsx file into a gridView. The .xls/.xlsx file is successfully imported into a gridView. There are a columns named Date, Name and Total in my gridView. How can I get the value from that dataGridView? I want to get all the...

Crystal Reports only shows the last column

vb.net,datagridview,crystal-reports
since i am new to crystal report i have search for 3 hours still couldn't find the right answer to my problem. please check my code. Dim rptsumrep As CrystalDecisions.CrystalReports.Engine.ReportDocument Dim sda As New MySqlDataAdapter Dim bsource As New BindingSource Dim dtincom As New DataTable dtincom.Clear() conn.Open() Dim queryIncom As...

Windows Form: change dataGridView's first cell origin?

c#,winforms,matrix,datagridview
Long story short, I have this dataGridView and I want the cell [0,0] to be the cell on the lower-left corner of the grid, not on the top-left of the grid like it does by default. For example, visually, if i do something like: dataGridView1[0, 0].Value = "a"; I get...

Create a DataGrid in WPF with column type equal with DataGridViewButtonColumn of WinForm

c#,wpf,datagridview,wpfdatagrid
In WinForm i can programmatically add Rows on a DataGridView column(s) with loop, let say like this private void rowsAdder() { for(int u = 0; u<= 10; u++) { classSelect.Rows.Add("Number " + u); //classSelect is a name of a DataGridView, where the first column is a DataGridViewButtonColumn } } Then...

DataSet using first row as column header move the checkbox column 1 row down

c#,datagridview,dataset
I have DataSet which i populate from Excel file: OleDbConnection conn; OleDbDataAdapter command; conn = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + filePath + " ';Extended Properties=Excel 8.0; "); conn.Open(); firstSheetName = GetFirstSheet(conn); command = new OleDbDataAdapter("select * from [" + firstSheetName + "]", conn); command.TableMappings.Add("Table", "Table"); dtSet = new DataSet(); command.Fill(dtSet); dgvInputFile.DataSource...

Adding contents of a DataViewGrid to access - VB

vb.net,gridview,datagridview
I've got quite the frustrating issue! My VB code below is intended to transfer the records in a DataGridView to an Access database. Let's say, for example, the gridview has three records Name|House|Age John|L|1 Rick|B|12 Fred|A|20 The 'name|house|age' is the header of the GridView, whilst the three records make up...

Getting data from selected dataGridView to string

c#,datagridview
So I'd like to extract a selected data from dataGridView to string variable but I seem to have gone wrong somewhere in the code. How do I go about this? Below is what I'd written but it doesn't seem to be right. if ( dataGridView1.SelectedRows.Count != null) { string itemid...

Array of DataGridViews in C#

c#,winforms,datagridview
I am working on a program that contains multiple DataGridViews on multiple tab controls. My DataGridViews have a lot of initial formatting done to them at runtime. For example, row 0 and 1 are my first set of "headers" which are read only cells with color and font formatting. Rows...

XmlReader.Name returns an empty value

c#,datagridview
I am reading in data from an external server. The data comes in fine and I can set all the text values but when I try to read in tagname there it doesn't work. My overall goal is to populate a dataGridView with tag names in one column and tag...

System.DBNull Error on formatting DataGridView C#

c#,.net,datagridview
I'm new to C# so I have been following some guides and adapting it to fit my application. Here is one of the ones I followed from Microsoft. I have used the same code as what they have suggested and I get an error. My code simply looks at the...

How to display entered string from textbox in ordered list in c#?

c#,datagridview
I have the following requirement : There is one text box. Whenever I type a string in textbox and press ENTER, that particular string should be appended to the datagridview and textbox should be cleared. Again the same process repeats. I am new to C# , any suggestion where to...

Filling DataGridView row by row only populates last row

vb.net,excel,datagridview,oledb
I'm trying to fill a datagridview with one column of integers using a loop. I'm pretty sure I've got the loop and excel reference correct, as I've used this on other projects, but it won't display correctly. Here's the code: Dim da As OleDbDataAdapter Dim ds As DataSet xlWorkbook2 =...

How to write a T-SQL Stored Procedure to return data from three database tables

c#,sql-server,stored-procedures,datagridview
I have to display data from following three tables ('dbo.BookAuthor' is the mapping table). Database Diagram I need to write a stored procedure to retrieve data from a stored procedure and fill that data to a DataGridView as follows. DataGridView to display above data Please help me to write SQL...

Showing Database Search results in Datagridview

c#,sql-server,winforms,visual-studio-2013,datagridview
I am using Visual Studio 2013 with SQL Server 2012 for database in my Windows forms application c#. I want to show my query search results in a DataGridView: public void customerSearch(int custID, DataGridView dataGridView) { try { SqlConnection connection = new SqlConnection(@"Connection String"); connection.Open(); SqlCommand searchQuery = new SqlCommand("select...

Displaying rows from table into datagridview with matched column value

c#,datagridview,datatable
I have a list of string which contain names and a database table what i want to do is to display the rows from the table in datagridview. All rows which contain the name column value same as any of the list item will be displayed into datagrid view.I wrote...

Generate sheet separated excel with GridView in MVC web enviroment

c#,asp.net,asp.net-mvc,excel,datagridview
I use the following code, and I'm wondering if I can somehow make this a sheet separated excel file with each row in its own sheet. DataTable dt = new DataTable(); SqlConnection objcon = new SqlConnection(connectionString); string sql = "SELECT * FROM table"; SqlDataAdapter objda = new SqlDataAdapter(sql, objcon); objda.Fill(dt);...

Sending data from a class to a DataGridView

c#,datagridview
Its a Window Form Application where i have created a linked list. one of my functions is a search function, it accepts an argument from the user and searches the linked list based on the input and outputs everything in the Nod releated to it(Nod contains FirstName, LastName,Telephone) outputs it...

Set column visibility (properties) of added datagridview prior to adding the control to the form

vb.net,winforms,datagridview
GD All, I've got a loop for a fairly simple form that adds tab pages for a selection of records. On the added tabs it inserts a DataGridView to display the selection of the records per tab identifier. In order to do this I've created below code: For Each r...

Merge DataGridView Image cell with text cell

c#,vb.net,image,winforms,datagridview
I'm looking for cell painting code to merge a datagridview image cell with a text cell, like the image to be on top and text at the bottom. I was asked to find a way of showing people pictures with job title and department. I was able to merge job...

How can I create a footer for cell in datagridview

c#,winforms,datagridview,cell
I need to create a DataGridView with cells that have two parts. One part is the content of that cell such as 0, 1 etc value. And the remain part is the footer of that cell, just like a footer of a word document, refers to the ordinal number of...

Changing date format in datagridview

c#,excel,datagridview,date-format
I have an excel file which contain two columns of dates, the format of the date is mm/dd/yyyy . Now I am exporting it to my DataGridView and save it to my database. But after saving it, the format of the dates are changed, it is mm/dd/yy hh:mm:ss. How would...

Fill two datagridviews from one tableadapter

vb.net,datagridview,dataadapter
Is it possible to fill two DataGridView (named as Datagridview1 & Datagridview2) from one dataset < one tableadapter < 2 Different queries From query 1 = DGV1 i need to fill datagridview1 From query 2 - DGV2 i need to fill datagridview2 ...

Remove last row from DataGridView row count

c#,visual-studio,datagridview,foreach,rowcount
I've create a foreach loop in C#. I'm trying to loop trough all the rows except for the last one, which is automatically added. Since the cells contains no values I'm getting a NullException. Important: Setting AllowUsersToAddRows to false is not an option as this function is required. foreach (DataGridViewRow...

Uploading excel file to DataGridView

c#,excel,datagridview
I am currently making a program on uploading excel file to datagridview. I am thinking of making it flexible and more user friendly. My question is, is it possible to set what row or what column to start the upload of the excel file? Because what I am doing right...

Cancel some keyboard events on a control

c#,.net,datagridview,event-handling
I have a DataGridView with KeyDown and KeyUp handlers. Under some conditions I want to disable the default behavior of the Enter key down (unselecting text and focusing on the next row), pretty much like this: private void View_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter && Condition) {...

Selecting different connection strings for data gridview

vb.net,datagridview,sqldataadapter
Why is this not straight-forward? I have two databases that contain a log-table each. I have a stored procedure that extracts the data from the table. I have a datagridview on a windows form, and a drop-down box to select the connection string for the respective databases. On selection of...

Improve DataGridView rows managing

.net,vb.net,winforms,datagridview,datatable
SCENARIO I'm manually filling a DataGridView with a DataGridViewRow collection: I created the columns at design time in the GUI builder of Visual Studio. First column takes an Integer value, its a DataGridViewTextBoxColumn. Second column takes an Icon object, its a DataGridViewImageColumn. Third column takes a String value, its...

Adding new row in DataGridView doesn't add to BindingList

c#,datagridview,row,bindinglist
I've a little problem using a DataGridView with AllowUserToAddRows set to True that is binding to a list (BindingList<State>). When adding a new row through the GUI, the row isn't added to the BindingList. I've a entity which contains a collection with other entities. For example: Country contains States. So,...

DataGridView getting the background colour

c#,datagridview
I can't seem to return the background color of the current cell in my DatagridView. As an example lets say that the background Style.BackgroundColor color of all the cells in my grid are Color.Pink Code: private void grid_CellEnter(object sender, DataGridViewCellEventArgs e) { var cell = grid.CurrentCell; var colour = cell.Style.BackColor;...

visually select datagridview cell

c#,datagridview
I am trying to use a datagridview as a "tag" mesh. I have a number of objects that I want to set and edit "tags" for. Each cell in the datagridview has a string tag in it, the datagridview is multi-select, so the user can select a whole lot of...

Save Calculated Value from Spawned Child Form to Parent After Button Click

c#,forms,winforms,datagridview
I have a Winforms Form and I spawn a Route Calculator in a DataGridView Control. After client inputs, it does the calculation and then updates a textbox on the same form after "Update" is pressed. How can I make it so that the value from this textbox in the spawned...

C# - Creating 2 dimensional array from multiple datagridviews

c#,arrays,datagridview
I am relatively new to c# and am having a problem filling a 2 dimensional array. public string[,] myGridData = new string[50, 5]; The array data is contained in 7 datagridviews, each with 7rows x 5 columns. I know how to get the data from the first grid, but am...

Tab Indexing is circulating in datagridview rows not moving to next control in windows form, c#

c#,winforms,datagridview,tabindex
If tab index is on last row and column of datagridview, if I press tab key at this point, it is moving to the first row and column of datagridview instead of next control(button). Can someone suggest me how to stop the tab indexing on last row and move to...

C# Validate DataSet filled with DGV data as XML

c#,xml,validation,datagridview,xsd
I want to make a "Save as" button which will validate data from dataGridView with .xsd XML schema before saving it as an XML file. The idea was to save DataTable filled with DGV data as an XML, validate it with .xsd and delete it if the file is valid...

Null values are creating error in datagridview in vb.net

vb.net,excel,datagridview
So i am importing the Excel sheet into datagridview. But unfortunately some empty tuples are included inside. The image will be of some help. The extra NULL tuples are 41 and 42. Now when i am calculating the percentage from the data of these tuples with a loop, the loop...

Selecting and highlight a DataGridView row by checking a checkbox

powershell,checkbox,datagridview
$Form = New-Object System.Windows.Forms.Form $Form.Text = "testform" $Form.Size = New-Object System.Drawing.Size(250,300) $Form.StartPosition = "Centerscreen" $button = New-Object System.Windows.Forms.Button $button.Location = New-Object System.Drawing.Size(50,100) $button.Size = New-Object System.Drawing.Size(140,30) $button.Text = "Click Here" $button.Add_Click({[void] $form1.ShowDialog()}) $Form.controls.Add($button) $form1 = New-Object System.Windows.Forms.Form $form1.Size = New-Object System.Drawing.Size(500,600) $Form1.Text =...

How to set a data grid column to be a drop down when binding to a table

vb.net,datagridview,datagridviewcolumn,datagridviewcomboboxcell
I am able to create a data table and bind it to a datagridview. If possible I want something more sophisticated. I want to limit the first column to values 1 to 12 and the 2nd column to either AM or PM. Thanks in advance. mDataTable = GetTable() DataGridView1.DataSource =...

XmlReader DataGridView flip column and rows

xml,vb.net,datagridview
Using VB.NET I'm binding a DataGridView to an XML file using this code (for reading and writing) Global: Dim ds As New DataSet Dim sFile As String = "C:\test.xml" Reading: Using xmlFile As XmlReader = XmlReader.Create(sFile, New XmlReaderSettings()) ds.ReadXml(xmlFile) gridData.DataSource = ds.Tables("data") End Using Writing: ds.WriteXml(sFile) Here is what the...

Comparing DataGridView values

c#,winforms,datagridview
I have a WinForms application in C # that registers support tickets in a DataGridView, each ticket has a status, which may be pending or completed. I want to implement a method to validate if a ticket is completed, then this record can not be modified. What i tried was...

Wrong row gets deleted in DataGridView bound to DataAdapter

c#,mysql,datagridview,delete-row,dataadapter
Situation: I'm writing a Winforms app using C# in VS2013 with .NET4.0. I have a datagridview which I bind to a DataAdapter linked to a MySQL table. I'm performing updates using the DataAdapter's Update method. Due to the unconventional handling of dates and booleans in the MySQL table I set...

How to unhighlight row in dataviewgrid C#

c#,datagridview,datatable
I have created a dataviewgrid with different column. I have kept selection feature by which one can get selected row by a button click and prompt an error when the row is not selected on button click. I see that the first row in table is always selected. Is there...

Split comma separated strings 5 [closed]

c#,windows,datagridview,textbox
I have 5 values in datagridview column with comma like abc,xyz,asdf,qwer,mni how to split into string and display in textbox abc xyz asdf qwer mni ...

Handling concurrency exceptions in DataGridView

c#,vb.net,winforms,datagridview,dataset
This article here describes handling concurrency exceptions. The steps to reproduce the problem are: Create a new Windows Application project. Create a new dataset based on the Northwind Customers table. Create a form with a DataGridView to display the data. Fill a dataset with data from the Customers table in...

Accessing a Combobox inside a dataGridView Column?

c++,datagridview,visual-c++-2010,datagridviewcombobox
I'm working on a scheduling program, and inside the dataGridView, we have a few ComboBox Columns that are populated by 3 entries upon creation, but I wanted to be able to add more as the user creates them, but I have no idea how you would access the combobox data....

dataview.rowfilter syntax error - missing operand mystery

vb.net,datagridview,datatable,dataview,rowfilter
Weird, weird error. I might just be codeblind, but: Dim dtdv As New DataView dtdv = dt.DefaultView dtdv.RowFilter = "Controller ID = 'PS2USB1'" XMLDGV.DataSource = dtdv produces, at line 3: Missing operand after 'ID' operator. dt defined and correct. Column heading correct. Weird. Any ideas?...

DropDown in datagridView

c#,visual-studio-2013,datagridview,combobox,ssms
hello i have 2 datagridViews in a windows form and i have a combobox in 1 datagridview somwthing like this when i change the value of the combobox the tables in the datagridview should be updated.For example if i select the second combobox as outputmetadatafield1 then the columns of that...

Last checked row in datagridview checkbox column is not checked

c#,datagridview,datagridviewcheckboxcell
I have DataGridView populated from excel file. I added checkbox column to this datagridview ... dtSet.Tables[0].Columns.Add(new DataColumn("boolCol", typeof(bool))); dgvInputFile.DataSource = dtSet.Tables[0]; dgvInputFile.AllowUserToAddRows = false; Later I'm checking if each row is cheked: for (int currentRow = 0; currentRow < grv.Rows.Count; currentRow++) { DataGridViewCheckBoxCell CbxCell = dgvInputFile.Rows[currentRow].Cells["boolCol"] as DataGridViewCheckBoxCell; bool valid...

Calculation from Zoomable Graph C#

c#,graph,datagridview,charts,axis
Basically I have a graph that is bound from a DataTable which source is from a DataGridView. I have zoomable functions on the graph and I need it use X Axis SelectionStart and SelectionEnd in order to calculate the block of data that is selected. So I have some minimums...

Updating a list of objects bound to a DataGridView from a popup form

c#,winforms,datagridview
I seem to be having a bit of a problem with returning the updated information on my edit button placed on the popup form, back to my DataGridView (which is bound to a list of objects) on the original form. I seemed to have it working the other day, however,...

Binding Source NOT reflecting new/removed Row when List datasource adds/removes item

c#,datagridview,bindingsource,bindinglist
So I tried using both BindingList and BindingSource, but the issue is the same with both. Just for some background: I have a application where I receive updates on trading objects from an api. I receive real time the updates from the api (Can be an add/update/remove updateType) and process...

Insert column with different values after binding DataGridView

datagridview,cell
I have a DataGridView: dgvPersonnelInfo.DataSource = personnelInfo; Now I add a column as follows: var arabicYear = new DataGridViewColumn(); arabicYear.Name = "arabicYear"; arabicYear.HeaderText = "Arabic Year"; arabicYear.CellTemplate = new DataGridViewTextBoxCell(); dgvPersonnelInfo.Columns.Insert(4, arabicYear); Then I want to assign the value of this cell as follows: for (int i = 0; i...

Object reference not set to an instance of an object on retrieving text from datagridview

datagridview,vb.net-2010
I have a Datagridview that is bound to a database using binding source. I want to highlight the row or text that has the value that I am searching. But for some reason, it gives me this error: Object reference not set to an instance of an object. It points...

Saving Data To DataSet That Has Been Set Up Programmatically

vb.net,datagridview,dataset
I am building a form where I need to programmatically set bindings and the dataset (as it is variable and different documents can be loaded in to it). I've managed to get the form to load any information in to a DataGridView and also load that information from the DataGridView...

{“Object reference not set to an instance of an object.”} [duplicate]

c#,winforms,datagridview
This question already has an answer here: What is a NullReferenceException and how do I fix it? 17 answers I'm using the code below in order to select the data from a database and bind a datagridview, but I'm having this error and all the questions asked before by...

VB.NET XtraGrid Change cell color after its value is edited

.net,vb.net,datagridview,devexpress
How can I change the XtrsGrid's (GridControl) cell background after its value has been updated/changed/edited? Can I do it in following event: AddHandler grdView.RowCellStyle, AddressOf grdView_RowCellStyle But this changes the color of whole Grid cells. Private Sub grdView_RowCellStyle(sender As Object, e As RowCellStyleEventArgs) e.Appearance.BackColor = Color.Blue End Sub EDIT: I...

How to filter and show only selected items in datagridview?

c#,checkbox,datagridview
I have a datagridview and recently I got task to add a checkbox column (which I did) and a button (btnFilter) that will filter/show only selected rows so for example if I check only 4th, 5th and 6th row and click on 'btnFilter' the datagridview would show only rows 4,5...

Move up or down little complex DataGridView rows with multi-selection

c#,.net,vb.net,winforms,datagridview
I have a DataGridView like this: Now, In C# or else VB.Net, with a button, I would like to move up or down one position the selected rows, how I could do it?. The multi selection requisite complicate me this. The files that appear in the DataGridView will be combined...

DataGridView KeyDown manipulation (enter, left, right, etc.) not working when multiselect

c#,winforms,datagridview,multi-select
I want to make the DataGridView more handy while manipulating the KeyDown event, like the KeyEnter for moving one cell to the right, or using left, down or up. I have some special use cases where I want to check first the cell and depending on that I can discard...

How to add empty value from gridview cell to list?

c#,linq,list,datagridview,datagridviewtextboxcell
I want to enter guest details(Title,Firstname,midname lastname) in a list<string> ,the guest details can be empty.I'm using LINQ for inserting in the list.I had referred this question for the LINQ code DataGridView write all values from a column to list All I want to do is enter the text into...

Operator '-' is not defined for type 'Double' and type 'DBNull'. [vb.net datagridview]

datagridview,vb.net-2010
Here I am getting the following bracketed error (Operator '-' is not defined for type 'Double' and type 'DBNull'.) when executing the NetValueValidation(). But its working in the column of "discper" after executing DiscPerValidation() Private Sub grdPurchase_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles grdPurchase.CellEndEdit CellEdited = True CurrentColumn...

Not getting values from grid table when checkbox is checked?

c#,winforms,datagridview,datagridviewcheckboxcell
I want to get value of row where checkbox is checked. I am new to C# windows forms and so far unsuccessful. I want to eventually use these row values, so if user selects multiple row and then I should get value for those checked. Also, I have set the...

Get all last transactions and sum all and view in datagridview

sql,vb.net,datagridview
I've searched for the solution for my issue but from what I've read, I am puzzled on how to incorporate it in my program. I have one table. I just want to get all the last transactions of each Employees and sum all of them. Example: |EmployeeID| |Date| |Amount| 101...

Visual Basic Datagrid View change row colour

vb.net,datagridview,datagrid
Every other change to the datagrid view works fine but for some reason the row color just wont change. Ive debugged and my application goes through the loop to change the row color. Also I have a button that gives the datagrid view a new list and colors the rows...

Cannot make DataGridView to bind to data source more than once

c#,multithreading,winforms,data-binding,datagridview
I have a Winforms GUI app. I have a list of simple class called FinishedTests_Loops_DGV. This list is being added in a different thread (timer thread). After new class is added to the list (inside timer thread), I call updateLoopsDGV() which invokes the DataGridView and updates it: public void updateLoopsDGV()...

Datagridview : row moves after an update, why?

.net,vb.net,postgresql,datagridview,odbc
I make an application in vb.net code using the visual basic 2010 environment and i have a little problem whith the datagridview. For more details, i have connected a postgresql database using the connector odbc and it work fine. I can insert, update, delete datas easily but after an update...

changing the order of records in dataset

c#,winforms,datagridview,dataset
I'm trying to sort the records at a dataset according to users preference. I add a button (move up) to bump up the selected record 1 row higher and this is what i have done until now: private void btnMoveUp_Click(object sender, EventArgs e) { int index = dataGridView1.CurrentRow.Index; if (index...

How to read datarow selected object properties into another Windows Form using bindingSource

c#,winforms,datagridview,bindingsource
Well, here is my problem.I've got Form1 and datagridview on it, I want to pass values of selected object from datagrid to Form2 into textBoxName and textBoxQuantity using bindingSource on Form2. Here are the pics(sorry,but I can't put them directly because of 10min points restriction) http://i58.tinypic.com/hwy6g0.jpg http://i60.tinypic.com/20fdt14.jpg So far, I've...

Filtering by user input getting error message can not get table 0

c#,visual-studio-2013,datagridview
I have wrote code following a tutorial posted here http://csharp.net-informations.com/datagridview/csharp-datagridview-filter.htm However I keep getting the error "Cannot find table 0", I have tried several things but none have worked i have posted the code in my form load and the button to start the process string connectionString = "server=localhost;user id=root;database=epas=";...

Restricting the input in DataGridView c#

c#,datagridview,combobox
So I have a DataGridView in a form, and I want to restrict adding data to its cell. I'm trying to make the cells of any added row a combobox, so that the user will have to choose the data for the cell from the combobox. Also when a user...

export datagridview header column to excel vb 2012

vb.net,excel,datagridview
i'm using visual studio 2012 and microsoft SQL server 2012 to export datagridview to excel using this coding: Public Class Export Private Sub Export_Load(sender As Object, e As EventArgs) Handles MyBase.Load DataGridView1.AllowUserToAddRows = False ClassKoneksi.namadatabase = "KPIRWAN" Dim dssiswa As New DataSet Dim sql As String sql = "select*from Siswa...

Two datagridviews bound to the same table. Refresh not working

c#,mysql,datagridview,refresh,dataadapter
Situation: I'm writing a Winforms app using C# in VS2013 with .NET4.0. On a tabbed control I have two tabs. In the first I have a dgv bound via a data adapter to a MySQL "product" table and also a dgv bound to a MySQL "stock" table. These are related...

Display value from datagridview to textbox in other form c#.Net

c#,vb.net,winforms,datagridview,textbox
I'm a C#.Net Beginner! I have 2 forms Mainform and Derogatory form.. My datagridview is in the Mainform, then my textboxs is in the derogatory form. Question: How to display value from datagridview in Mainform to texthbox in Derogatory Form after clicking the cell of datagridview from Mainform? this is...

update multi-table dataset via datagridview vb

xml,vb.net,datagridview,dataset
Apologies - I know there's lots of info out there about this subject, but that's precisely the problem - so much info about this - hard to piece it all together to understand/get it working. So many concepts and approaches involved. Basically have read an xml file into a Dataset....

Display member of class in DataGridView

c#,winforms,datagridview
I have two classes: public class Client { public int Id {get; set;} public string Name {get; set;} public AboutClient ClientInfo {get; set;} public Client (int id, string name, AboutClient aboutClient) { Id = id; Name = name; ClientInfo = aboutClient; } } public class AboutClient { public int Id...

Get Selected Row in DataGridView not working VB.Net

vb.net,datagridview,selectedindex
I have a pretty standard DataGridView and have already used .SelectionMode = DataGridViewSelectionMode.FullRowSelect .MultiSelect = False in order ensure the entire row is selected. Situation : I need to obtain the selected row in order to load the data in the row to another screen to "Modify" the data. I...

How can I make DataGridView.Rows.DividerHeight work?

c#,.net,winforms,datagridview
I have tried to make a simple sudoku Interface using dataGridView. The problem is that I can't get DividerHeight to work. The code below is able to change the width of the vertical divider, but not the horizontal divider: public partial class Form1 : Form { private DataTable sudokuTable; public...

How to Register the RowLeave event

c#,winforms,datagridview
I have a form in VSTO addin. I want to register the FormX_RowLeave() method. I register functions like this since I am using visual designer. this.clientsProjectHistoryDataGridView.CellLeave += new System.Windows.Forms.DataGridViewCellEventHandler(this.clientsProjectHistoryDataGridView_CellLeave); But I don't know how to do this with RowLeave. I can't find any examples or find it in the docs....

Unable to bind data to DataGridView by using BindingList in WinForm application

c#,excel,winforms,datagridview
I am reading data from excel file (.csv) and storing that data to List<String>. I want to display this data to DataGridView but for some reason I am seeing total length of String in Grid. Following is my code : CODE: private void btnImportFile_Click(object sender, EventArgs e) { OpenFileDialog dialog...

Stopping / cancelling BackgroundWorker

c#,multithreading,winforms,datagridview
I have created an application which generates multiple background workers. The premise is that I have a datagridview and in that I have a button column. The button column changes it's name to Start and Stop. Following is the code for the button click private void dgConfig_CellClick(object sender, DataGridViewCellEventArgs e)...

How can i make excel like grid in asp.net C# Webform

asp.net,gridview,datagridview,webforms
How can I make a grid like in Excel in ASP.NET WebForms? I would like rows and coloms where user can enter data and after a click on a save button the data would be inserted into a database....

How to store multiple records in SQL Server using DataGridView

c#,sql-server,datagridview
I'm trying to insert 5 records into a SQL Server database table from DataGridView using C#. From my code it takes input of several records but insert only first record in database. Can anybody help me to save 5 records in database by a single click of save button? Here...

How to Require Confirmation on Form Close When there is Changed Data in a DataGridView

c#,winforms,datagridview
I have simple Form1 with datagridview and I've enabled editing and adding. Now, when I click on closing form button, and if some of existing cell values are changed or new row has been added I want dialogue box to open (for example, asking me if I want to save...

DataGridView Cell value not available for validation when inserting a new row

c#,validation,datagridview
Situation: I'm writing a Winforms app using C# in VS2013 with .NET4.0. To carry out cell level validation in a DataGridView I handle the CellValidating event. When validating I access the user input values with dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value For the validation of existing rows this works fine. Issue: When the user types...

Validation DataGridView Windows Forms

c#,winforms,entity-framework,validation,datagridview
I have two forms with grid views, one made from a database data source and one from entity framework dbset's. The EF one, when I press add row it adds a row and I can edit the ID. The other form, when I add row the ID is negative. Rather...