datagridview

DataGridComboBoxCell - Can't Fill Values Programmatically

邮差的信 提交于 2021-02-11 12:36:01
问题 I'm filling a DataGridView with 2 columns, a DataGridViewTextBoxColumn for a name label, and a DataGridViewComboBoxColumn to act as a dropdown for selecting an SQL Column name to map to the name. I'm going for a loop through my names, and creating a row for each of them. Each row should display the name of a field ( String object), and in the other column should be a combo box (values are within a List (Of String) ). I keep getting an exception raised that says 'the value is not valid': For

Formatting dataGridView

五迷三道 提交于 2021-02-11 12:35:50
问题 I have a data in dataGridView like this: codetrans | datetrans | codeitem ----------+-----------+---------- CDTRS1 | 2015/9/14 | BR01 CDTRS2 | 2015/9/15 | BR02 CDTRS2 | 2015/9/15 | BR03 My question is how to change forecolor when codetrans and datetrans is the same, but codetrans and datetrans index won't change? private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.DataGridView.Equals

Use a virtual Keyboard on focused Textboxes and DataGridView Cells

最后都变了- 提交于 2021-02-11 07:38:21
问题 In my Form I have various Textboxes that I write into with an in Form keyboard I created using Buttons. I have this code in Form.Load, which uses an event handler to determine which Textbox has the Focus: For Each control As Control In Me.Controls If control.GetType.Equals(GetType(TextBox)) Then Dim textBox As TextBox = control AddHandler textBox.Enter, Sub() FocussedTextbox = textBox End If Next Then I use this on each button to write a specific character: Private Sub btnQ_Click(sender As

Use a virtual Keyboard on focused Textboxes and DataGridView Cells

扶醉桌前 提交于 2021-02-11 07:37:51
问题 In my Form I have various Textboxes that I write into with an in Form keyboard I created using Buttons. I have this code in Form.Load, which uses an event handler to determine which Textbox has the Focus: For Each control As Control In Me.Controls If control.GetType.Equals(GetType(TextBox)) Then Dim textBox As TextBox = control AddHandler textBox.Enter, Sub() FocussedTextbox = textBox End If Next Then I use this on each button to write a specific character: Private Sub btnQ_Click(sender As

What index does dataGridView start at?

风流意气都作罢 提交于 2021-02-11 06:54:41
问题 foreach (DataGridViewRow item in this.dataGridView1.SelectedRows) { if (Int32.Parse(item.Cells[1].Value.ToString()) >= Int32.Parse(textBox4.Text) ) { dataGridView1.Rows.RemoveAt(item.Index); } } I'm trying to check if the integer in the second column is at least the value in textBox4. However, nothing is removed when I run this, so I feel it's not comparing the right column. Do C# columns count from 0 or from 1? 回答1: What index does dataGridView start at? It starts at 0. 回答2: dataGridView's

C# Visual - Datagridview search if textbox = cell string

≯℡__Kan透↙ 提交于 2021-02-11 06:19:29
问题 I am trying to make it so that when you enter data into DataGridView it first checks if the ID textbox contains a string that exists in the DataGridView ID column and throws an error if it finds a match. If it does not match then the system can add the data. I tried all kind of codes that people posted nothing worked. here is my latest. private void btnadd_Click(object sender, EventArgs e) { Label label25 = new Label(); foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells[0]

C# Visual - Datagridview search if textbox = cell string

瘦欲@ 提交于 2021-02-11 06:19:15
问题 I am trying to make it so that when you enter data into DataGridView it first checks if the ID textbox contains a string that exists in the DataGridView ID column and throws an error if it finds a match. If it does not match then the system can add the data. I tried all kind of codes that people posted nothing worked. here is my latest. private void btnadd_Click(object sender, EventArgs e) { Label label25 = new Label(); foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells[0]

C# Visual - Datagridview search if textbox = cell string

烂漫一生 提交于 2021-02-11 06:18:15
问题 I am trying to make it so that when you enter data into DataGridView it first checks if the ID textbox contains a string that exists in the DataGridView ID column and throws an error if it finds a match. If it does not match then the system can add the data. I tried all kind of codes that people posted nothing worked. here is my latest. private void btnadd_Click(object sender, EventArgs e) { Label label25 = new Label(); foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells[0]

How can I natural string sort a datagridview that is databound to a datatable

牧云@^-^@ 提交于 2021-02-11 06:12:07
问题 In my program, I have a datagridview that is bound to a datatable using a binding source. What I would like to accomplish to be able to sort the datagridview by a column using a natural string sort. Sample Column Data: XAB-1 XAB-2 XAB-11 XAB-3 XAB-1A XAB-10 XAB-1B Desired Result: XAB-1 XAB-1A XAB-1B XAB-2 XAB-3 XAB-10 XAB-11 I have tried using the datagridview.sort method passing in a natural string Icomparer, but the sort function cannot be used when the datagridview is databound. I have

How can I natural string sort a datagridview that is databound to a datatable

匆匆过客 提交于 2021-02-11 06:10:18
问题 In my program, I have a datagridview that is bound to a datatable using a binding source. What I would like to accomplish to be able to sort the datagridview by a column using a natural string sort. Sample Column Data: XAB-1 XAB-2 XAB-11 XAB-3 XAB-1A XAB-10 XAB-1B Desired Result: XAB-1 XAB-1A XAB-1B XAB-2 XAB-3 XAB-10 XAB-11 I have tried using the datagridview.sort method passing in a natural string Icomparer, but the sort function cannot be used when the datagridview is databound. I have