winforms

Prevent the application from exiting when the Console is closed

无人久伴 提交于 2021-02-08 14:38:17
问题 I use AllocConsole() to open a Console in a winform application. How can I prevent the application from exiting when the Console is closed? EDIT The update of completionpercentage from time to time is what I want to show in console void bkpDBFull_PercentComplete(object sender, PercentCompleteEventArgs e) { AllocConsole(); Console.Clear(); Console.WriteLine("Percent completed: {0}%.", e.Percent); } I tried the richtextBox as the alternative s =(e.Percent.ToString()); richTextBox1.Clear();

DataGridView DataSource Not Updating

隐身守侯 提交于 2021-02-08 13:52:49
问题 I am using Winforms DevExpress and I am binding a DataTable to a DataGridView which is working fine. The problem I am having is that I have some functions that will build a new DataTable object which is separate from the original which needs to replace the original DataTable that is bound to the DataGridView. DataTable originalTable = new DataTable("OriginalTable"); //Populate originalTable myDataGridControl.DataSource = originalTable; Everything works fine with the code above, but the

How can I create a button programmatically in C# window app?

倖福魔咒の 提交于 2021-02-08 12:01:19
问题 I know that it easy to just drag and drop a button, however a lecturer insists on creating buttons programmatically. In the Form1_Load method what code should I write to create a simple button? private void Form1_Load(object sender, System.EventArgs e) { } So that on Load the button would show? 回答1: As you said it is Winforms, you can do the following... First create a new Button object. Button newButton = new Button(); Then add it to the form inside that function using: this.Controls.Add

How to get DataGridViewRow from CellFormatting event?

不问归期 提交于 2021-02-08 10:41:29
问题 I have a DataGridView and handle event CellFormatting. It has a parameter called: DataGridViewCellFormattingEventArgs e With e.RowIndex in it. When i do: DataGridView.Rows[e.RowIndex] I get proper row from collection. But when I click at a header of a column to sort it by other column than default one and user DataGridView.Rows[e.RowIndex] I get unproper row. It is because Rows collection do not reflect order of rows in DataGridView. So how to get propert DataGridViewRow from RowIndex in

Index was out of range after deleting multiple rows from the datagridview? C#

自古美人都是妖i 提交于 2021-02-08 10:13:08
问题 I use an ArrayList for my binary search. The datagridview's rows is added to the ArryList. When I deleting a single row from the datagridview, it works almost perfectly. The problem is when I delete many rows from the datagridview from the top or the bottom and middle, it gives me an error. How can I refresh or update the ArrayList after I deleted a row from the ArrayList (datagridview)? The error: 'Index was out of range. Must be non-negative and less than the size of the collection.

WinForms DragDrop path length limitation

久未见 提交于 2021-02-08 10:12:44
问题 I'm using WinForms and have a DragDrop operation that handles a file being dragged onto the window. This works fine but if the path to the file is very long it just fails. string[] fileList = (string[]) e.Data.GetData(DataFormats.FileDrop, false); results in fileList being null . Does anyone know what the limitation is or any way to work around it? Thanks! Update: The data in GetFormats is as follows: Short Filename: Shell IDList Array UsingDefaultDragImage DragImageBits DragContext

WinForms DragDrop path length limitation

↘锁芯ラ 提交于 2021-02-08 10:04:53
问题 I'm using WinForms and have a DragDrop operation that handles a file being dragged onto the window. This works fine but if the path to the file is very long it just fails. string[] fileList = (string[]) e.Data.GetData(DataFormats.FileDrop, false); results in fileList being null . Does anyone know what the limitation is or any way to work around it? Thanks! Update: The data in GetFormats is as follows: Short Filename: Shell IDList Array UsingDefaultDragImage DragImageBits DragContext

WinForms DragDrop path length limitation

感情迁移 提交于 2021-02-08 10:04:20
问题 I'm using WinForms and have a DragDrop operation that handles a file being dragged onto the window. This works fine but if the path to the file is very long it just fails. string[] fileList = (string[]) e.Data.GetData(DataFormats.FileDrop, false); results in fileList being null . Does anyone know what the limitation is or any way to work around it? Thanks! Update: The data in GetFormats is as follows: Short Filename: Shell IDList Array UsingDefaultDragImage DragImageBits DragContext

Hide the border between two combined cells in TableLayoutPanel [duplicate]

与世无争的帅哥 提交于 2021-02-08 08:58:45
问题 This question already has answers here : Cannot remove spacing between controls in TableLayoutPanel? (3 answers) Closed 2 years ago . I have 4x4 table. How to make that the first row will have 2 cells only? Tried with ColumnSpan but it's still drawing borders between cells. Example: ---------------------- | A | B | ---------------------- | 1 | 2 | 3 | 4| ---------------------- 回答1: You can Dock a Panel with Margin=0 in a cell and then span that Panel to the desired size and use it as the

Configuring DataGridView Column

自作多情 提交于 2021-02-08 08:09:21
问题 I am working on a winforms project and I am having issues with DataGridView as I have never used it before. Issue 1: I have want the program to auto generate "MemberID" and it should not be editable by the user. Issue 2: I am working with database and I do not want "FamilyDetailFK" to be displayed, instead it should automatically be the value displayed by a TextBox in another part of the GUI. Issue 3: Is there any way the user can select "Relationship" from a drop down menu, so that means