datagridview

Search through datagridview not working - System.NullReferenceException error

若如初见. 提交于 2019-12-25 07:25:35
问题 I am trying to run a search through column 2 (data type: number) on my datagridview but keep getting the following error message: An unhandled exception of type 'System.NullReferenceException' occurred in SpeedyRent.exe Additional information: Object reference not set to an instance of an object. The error is being thrown at if (!string.Equals(row.Cells[1].Value.ToString(), driverNo.Text, StringComparison.OrdinalIgnoreCase)) What is it that I'm doing wrong? I've included my code below: void

Storing filtered rows of dataGridView in a DataTable

爷,独闯天下 提交于 2019-12-25 07:19:37
问题 I have a RadGridView control in my form. I bind DataGriView by one parameter by a search control. I use this code to store my selected rows in a DataTable and show in a report: DataTable table = new DataTable("dt1"); foreach (Telerik.WinControls.UI.GridViewDataColumn column in radGridView1.Columns) { table.Columns.Add(column.Name, typeof(string)); } for (int i = 0; i < radGridView1.Rows.Count; i++) { table.Rows.Add(); for (int j = 0; j < radGridView1.Columns.Count; j++) { table.Rows[i][j] =

Serial port data received handled too slowly

亡梦爱人 提交于 2019-12-25 07:01:15
问题 I am reading data from an arduino at a baud rate of 115200. The data comes in as a string on its own line in the format: <ID,Name/Data> . I believe that the problem with my code is that it is not handling the incoming data fast enough and the incoming data is being forced to wait for old data to be processed. The incoming string is split into the three separate categories (ID, Name, Data) and added to a data table called dtFromGrid which is bound to dataGridView1 . Is there any errors or

how to update data from datagridview with sqldatabse in vb.net

你说的曾经没有我的故事 提交于 2019-12-25 06:59:38
问题 i use another form editting data. when i double click the selected row in datagridview it will transfer the data in another form(frmEdit). i use this codes but it seems not working, how can i fix this. please help. Dim queryEdit As String = String.Empty queryEdit = "update dataContactDB set con_Name=@Name, con_Phone=@Phone, Address=@Address, Company=@Company, Gender=@Gender.text where con_Phone=txtPhone.text" Using conn As New SqlConnection(dbFunction.db) Using comm As New SqlCommand With

How I can update and delete rows in datagridview?

自闭症网瘾萝莉.ら 提交于 2019-12-25 06:49:55
问题 How I can update (via my popup)? //MyClass public partial class Orders : Form { BindingList<MyClass> blist = new BindingList<MyClass>(); public Orders() { InitializeComponent(); this.Load += new EventHandler(Form1_Load); } private void Form1_Load(object sender, EventArgs e) { } private void Add_Click_1(object sender, EventArgs e) { AddOrder addO = new AddOrder(); addO.ShowDialog(); this.dataGridView1.DataSource = blist; blist.Add(addO.mc); addO.Close(); } private void Delete_Click(object

C#: Bind DataGridView to a database file in the application directory

前提是你 提交于 2019-12-25 06:23:15
问题 I currently have a DataGridView bound to an sqlite database in "c:\temp". I bind it using the VS2008 GUI. I would like it to bind to a database in whatever directory the application is run from. I can see where the path has been hardcoded to "c:\temp\myapp.db", but if I change it in the generated code it will get overwritten when I recompile I think? How do I set it up so that the DataGridView connects to an sqlite db file in whatever directory the application is in? I'm very new to Winforms

vb.net / DataGridView / ComboBoxCell?

喜你入骨 提交于 2019-12-25 06:19:20
问题 I am using vb.net 2010 and winforms and DataGridView. The DataGridView has a DataGridViewComboBox column. When I show the form with the DGV it shows this and empty grid but the column that contains the ComboBox shows the first item on the dropdown list. How can I have the ComboBox display nothing until it is clicked on and selected? 回答1: Try setting the combobox selectedindex property to -1 when you initialize it. That might fix your problem, but when I do the same thing that you described,

Datagridview data load is giving error

旧城冷巷雨未停 提交于 2019-12-25 05:27:22
问题 I have a datagrid that consists of 3 comboboxcolumns and 2 textboxcolumns. I am loading my datagridview with data from the dataset. The data loads with an error always at the first combobox column.for each row,it displays the error and continues the load without issues. Error is : DataGridViewcomboboxcell value is not valid.To replace this default dialog please handle in the DataError event Can anyone explain why I have this error and how to overcome it? sql = "Select Sequence, ValueDate,

Form.Show causing to loose Row selection

做~自己de王妃 提交于 2019-12-25 05:14:44
问题 I am setting the current row using the following code private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { gSelectedPlant = StaticClass.GlobalValue; dataGridView1.CurrentCell = dataGridView1.Rows[gSelectedPlant].Cells[0]; dataGridView1.Rows[gSelectedPlant].Selected = true; gSelectedPlant = dataGridView1.CurrentCell.RowIndex; } In my second form which has a back button. private void btnCancel_Click(object sender, EventArgs e) { int plantid =

Form.Show causing to loose Row selection

亡梦爱人 提交于 2019-12-25 05:14:17
问题 I am setting the current row using the following code private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { gSelectedPlant = StaticClass.GlobalValue; dataGridView1.CurrentCell = dataGridView1.Rows[gSelectedPlant].Cells[0]; dataGridView1.Rows[gSelectedPlant].Selected = true; gSelectedPlant = dataGridView1.CurrentCell.RowIndex; } In my second form which has a back button. private void btnCancel_Click(object sender, EventArgs e) { int plantid =