winforms

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]

Document outline controls disabled in Visual Studio 2019 for .Net Core

喜欢而已 提交于 2021-02-11 04:31:25
问题 Now that .net core support WinForms projects, I've ported an old project to .Net 5. I can edit code, desing GUI and compile, and everything seems to work fine except for Document Outline window (in Visual Studio 2019). All four buttons, move up, down, out and into, are disabled, so I cannot choose what to see on top at desing time. I have created a new project from the scratch and those controls are still disabled. Demo image: Any idea why? I can guess it's something microsoft is working on,

Drag & Drop file from listview to windows explorer?

早过忘川 提交于 2021-02-11 02:48:50
问题 I have a bunch of files listed within a listview, and I want to know is it possible to drag and drop the files to Windows Explorer? If so how? I only seem to find examples of the other way around. Thanks! 回答1: So here's what I did. First off, in your listview, create an event handler for ItemDrag. Then the following.. private void listView_ItemDrag(object sender, ItemDragEventArgs e) { List<string> selection = new List<string>(); foreach (ListViewItem item in listView.SelectedItems) { int

Add new blank row to datagridview c#

时间秒杀一切 提交于 2021-02-10 23:40:16
问题 I have a DataGridView that has a DataTable as the DataSource . Now I want to insert a new empty row to the DataGridView and make it totally black (like a divider line). I have tried to copy one line and make it black with this: Datagridview1.rows.insertcopies(2,2,1); But I'm getting this error: rows cannot be programmatically added to the datagridview's rows collection when the control is data-bound. How can I keep the DataGridView the way she is and just insert a blank row? Clarification : I

Add new blank row to datagridview c#

ⅰ亾dé卋堺 提交于 2021-02-10 23:36:10
问题 I have a DataGridView that has a DataTable as the DataSource . Now I want to insert a new empty row to the DataGridView and make it totally black (like a divider line). I have tried to copy one line and make it black with this: Datagridview1.rows.insertcopies(2,2,1); But I'm getting this error: rows cannot be programmatically added to the datagridview's rows collection when the control is data-bound. How can I keep the DataGridView the way she is and just insert a blank row? Clarification : I

How to implement the keyboard key press in Windows Form Application

半腔热情 提交于 2021-02-10 22:32:44
问题 I want to implement the keyboard button press commands inside a c# windows form application. Suppose if some value is reached I want to implement the key "L" pressed using the windows form application.Is this possible ? How to do it ? 回答1: This might do the trick for you However, a better way is probably to set your form's KeyPreview property to true , and then put your code into the form's keyDown event (and set e.Handled = true as well, to prevent the key event from being passed on to

How to implement the keyboard key press in Windows Form Application

瘦欲@ 提交于 2021-02-10 22:30:25
问题 I want to implement the keyboard button press commands inside a c# windows form application. Suppose if some value is reached I want to implement the key "L" pressed using the windows form application.Is this possible ? How to do it ? 回答1: This might do the trick for you However, a better way is probably to set your form's KeyPreview property to true , and then put your code into the form's keyDown event (and set e.Handled = true as well, to prevent the key event from being passed on to

Powershell Textbox placeholder

删除回忆录丶 提交于 2021-02-10 20:42:39
问题 I create my from, define my TextBoxes, and for my placeholder text I'm using the following code: $AssetText.Add_MouseClick({ $AssetText.text = “” }) $ErrorText.Add_MouseClick({ $ErrorText.text = “” }) $IssueText.Add_MouseClick({ $IssueText = “” }) $TestTagText.Add_MouseClick({ $TestTagText.text = “” }) $TroubleshootText.Add_MouseClick({ $TroubleshootText.text = “” }) $ResolutionText.Add_MouseClick({ $ResolutionText.text = “” }) It works to remove text from the TextBox, but if I type a fair

Powershell Textbox placeholder

旧城冷巷雨未停 提交于 2021-02-10 20:41:32
问题 I create my from, define my TextBoxes, and for my placeholder text I'm using the following code: $AssetText.Add_MouseClick({ $AssetText.text = “” }) $ErrorText.Add_MouseClick({ $ErrorText.text = “” }) $IssueText.Add_MouseClick({ $IssueText = “” }) $TestTagText.Add_MouseClick({ $TestTagText.text = “” }) $TroubleshootText.Add_MouseClick({ $TroubleshootText.text = “” }) $ResolutionText.Add_MouseClick({ $ResolutionText.text = “” }) It works to remove text from the TextBox, but if I type a fair

Updates in the DataSource reset CheckedListBox checkboxes

为君一笑 提交于 2021-02-10 20:25:08
问题 I have a CheckedListBox, binded to a BindingList: private BindingList<string> list = new BindingList<string>(); public MyForm() { InitializeComponent(); list.Add("A"); list.Add("B"); list.Add("C"); list.Add("D"); checkedListBox.DataSource = collection; } When a certain button is clicked the list is updated: private void Button_Click(object sender, EventArgs e) { list.Insert(0, "Hello!"); } And it works fine, the CheckedListBox is updated. However, when some of the items are checked, clicking