FAQ Database Discussion Community


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...

How do I display an Icon on the Taskbar but not on the form itself?

vb.net,winforms,visual-studio
If I use ShowIcon in the form properties, I get the icon in the top left of my form (I don't want that), but I do get my icon in the taskbar. If I turn ShowIcon off, then I get no icon on the form but I get the default...

regular expression not working: repeated strings of digits

c#,regex,winforms
I was trying to create a regular expression to find repeated strings of digits. eg: 1 -not matching 11 -matching 122 -matching 1234 -not matching what i used is \d+. Tutorial are telling the "+" is similar to "*", except it requires at least one repetition. But when i tried...

Custom Numericupdown

c#,winforms,custom-controls
I'm trying to create a custom numericUpDown control. I'm trying to add text to the numericUpDown and I got it working good. But, now I want to find a way to select only the number when clicking in the control, because at this moment when I "edit" the value manually,...

Unable to modify variables from separate thread

c#,multithreading,winforms,text,file-io
So I'm making a C# app which has to continuously read and display the contents of a text file, while allowing the user to enter something into a text box and append it to the end of that very file. I'm doing this by running my read method on a...

What does ToolStripProfessionalRenderer.OnRenderItemBackground do?

c#,winforms,gdi,renderer,toolstrip
I am writing a custom ToolStripProfessionalRenderer component and currently working through all of the OnRender... overrides. This one in particular has stumped me: OnRenderItemBackground I can't see it drawing anything, so to force it to draw something I've done this: protected override void OnRenderItemBackground(ToolStripItemRenderEventArgs e) { e.Graphics.FillRectangle(Brushes.Red, e.Item.ContentRectangle); } ...but...

Form controls not showing

c#,forms,winforms,user-interface,user-controls
I'm making a console application that shows a form. I created the form from scratch. When I run the program, the form shows, but the controls I added don't show. My code: using System; using System.Windows.Forms; using System.Drawing; namespace form { public class main { public static void Main() {...

Why does this code to replace accented chars with html codes fail to work?

c#,html,winforms,diacritics,accented-strings
I want to replace accented chars (such as á, ñ, ¿, ¡, etc.) with the corresponding HTML codes (such as á, ñ, ¿, ¡, etc.). For example, this line of text: Imposible me ha sido rehusarme á las repetidas instancias que el Caballero Trelawney, el Doctor Livesey y otros muchos...

Load all user controls of a form on start

c#,winforms,events,user-controls
My Winform application has a main form with a tab control. In each tab there is a User Control. And each user control has Controls (such as DataGridViews, etc) that are loaded on the Load event of the user control. The problem I have is that I would like to...

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 append text correctly to replace part of original text

c#,winforms
I am having an issue inserting text into a textbox. Virtually what I am trying to do is copy a piece of text from 'richTextBox1', process it and then insert the processed data in 'richTextbox2' (there is already text in 'richTextBox2' above. The processed text should come underneath. The problem...

Check whether print command success or not

c#,.net,winforms,printing
I am printing some PDF files through c# code. My code looks like this myPrinters.SetDefaultPrinter(pdfPrinterName); var info = new ProcessStartInfo { Verb = "Print", FileName = file, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden }; var p = new Process { StartInfo = info }; p.Start(); p.WaitForInputIdle(); System.Threading.Thread.Sleep(18000); if (!p.CloseMainWindow()) p.Kill();...

How can i get a file name size in bytes and then reportprogress?

c#,.net,winforms
In the top of form1 i have a string array and a string file name: string[] stringProgressReport = new string[4]; string FileName = ""; Then in openfiledialog I'm getting the FileName. Then I have two events: private void videosInsertRequest_ResponseReceived(Video obj) { stringProgressReport[0] = obj.Status.UploadStatus; backgroundWorker1.ReportProgress(0, 0); } And private void...

Copying CMD output to clipboard

c#,winforms,cmd
I'm trying to copy output from a program running out of the CMD prompt to the Windows clipboard. private void button1_Click(object sender, EventArgs e) { /*Relevant Code*/ Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = String.Format("/k cd {0} && backdoor -rt -on...

How to add items to ComboBox as tree list

c#,winforms,combobox,tree
I have problem: I want show items in ComboBox as they are categorized. As shown in figure: I have two attributes in my table , one is vendorID , the other is vendorType . I want to show these vendor types in the ComboBox How I should do this?...

I'm getting exception Cross-thread operation since i'm using ui var in a thread operation how should i handle it? [duplicate]

c#,.net,multithreading,winforms
This question already has an answer here: Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on 12 answers I have this progress changed event: private void videosInsertRequest_ProgressChanged(IUploadProgress obj) { toolStripStatusLabel1.Text = obj.Status.ToString(); } And also this event: private void videosInsertRequest_ResponseReceived(Video obj)...

SaveFileDialog not displaying

c#,.net,winforms
EDITED CODE/QUESTION. BEGININVOKE IS NOT LONGER ON THE TABLE. I'm having trouble getting a SaveFileDialog to show its dialog. When I call ShowDialog normally I get no response at all. The code falls through and acts like the SFD was never called in the first place. I also tried running...

Is there a way in C#.Net to find the location of a textbox control on a Winform relative to the screen resolution?

c#,.net,winforms
I know the location property gives you the location of the control relative to the Winform it is on. But I want to know the x,y coordinates relative to the top left corner of the display, not the Winform. I had suggestions for using com interop and make an unmanaged...

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,...

How do i make backgroundworker reportprogress more then once from a different vars?

c#,.net,winforms
I added to form1 top a string array: string[] stringProgressReport; Then in one event i did: private void videosInsertRequest_ResponseReceived(Video obj) { string r1 = stringProgressReport[0] = obj.Status.UploadStatus; backgroundWorker1.ReportProgress(0, r1); } Then in a second event i did: private void videosInsertRequest_ProgressChanged(IUploadProgress obj) { string r2 = stringProgressReport[1] = obj.Status.ToString(); backgroundWorker1.ReportProgress(0, r2);...

how to fire a keydown or keypress event

c#,winforms,events,keypress,keydown
I want key press event fire without pressing a key by user. so I use InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_U); also System.Windows.Forms.SendKeys.Send("a"); that did not cause it so I use var key = Key.Insert; // Key to send var target = Keyboard.FocusedElement; // Target element var routedEvent = Keyboard.KeyDownEvent; // Event to send target.RaiseEvent(...

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....

Get parameters outside of Grouping Linq

c#,.net,winforms,linq
I need to get some Field's out of the Group using linq for example, this is my code: (from PaymentTypes in PaymentTypes_DataTable.AsEnumerable() join CashTransactions in CashTransactions_DataTable.AsEnumerable() on PaymentTypes.Field<Int32>("cashpaymenttype_id") equals CashTransactions.Field<Int32>("cashpaymenttype_id") into JoinedCashTransactions from CashTransactions in JoinedCashTransactions.DefaultIfEmpty() group CashTransactions by PaymentTypes.Field<Int32>("cashpaymenttype_id") into GroupPaymentTypes select new {...

Built in MessageBox Dialog Closing custom Form.ShowDialog()

c#,winforms
Okay Problem As Follows: I call up a custom form as follows: SomeCustomForm _newForm = new SomeCustomForm(); _newForm.ShowDialog(); //**SOME OTHER CODE** Now lets say we have some custom event (Mine is on a DataGridView DoubleClick): private void dgvSomeGrid_DoubleClick(object sender, EventArgs e) { string name = dgvSomeGrid.CurrentRow.Cells[5].Value.ToString(); DialogResult = MessageBox.Show(name, "Select...

Difference between OnClosing and Form_Closing or OnLoad and Form_Load

c#,winforms
I have a form in a VSTO addin. It has two methods, OnClosing and Form_Closing. What is the difference between these two? I can't seem to figure it out with any of the docs. Same goes for OnLoad and Form_Load. Thanks EDIT: Comment said that OnClosing is now OnFormClosing. Well...

Want to create function validating textbox with letters only

vb.net,winforms,visual-studio-2010
And another function to validate specific format like " ad12-XYX- 123-EFD-20" I have created the function for numbers only' I want something similar to this Private Sub AllowNumericonly(Byval CTRL As control) if not Isnumeric(ctrl.text) And Ctrl.test<> "" Then MSGbox("Please enter numbers only." , Vbinformation) ctrl.text = "" ctrl.focus() End if...

How can i add to the timer control a propert to display only hours minutes seconds without milliseconds?

c#,.net,winforms
In the control designer i have label1. In the designer the label text is set to: "00:00:00:000" Then the code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.Runtime.InteropServices; using System.Threading; namespace WinFormsUI { public partial class TimerControl :...

Set Label From Thread

vb.net,multithreading,winforms
Form1.vb Imports System.Threading Public Class Form1 Dim demoThread As Thread Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim Start As New Class1 Me.demoThread = New Thread( _ New ThreadStart(AddressOf Start.ThreadProcSafe)) Me.demoThread.Start() End Sub Delegate Sub SetTextCallback([text] As String) Public Sub SetText(ByVal [text] As String) ' InvokeRequired required...

Will this implementation using TPL work inside a process running on an STA thread?

winforms,task-parallel-library
I want to create an instance of an object from an assembly that implements an interface I define in my Forms app. I would create this object at app startup using Activator.CreateInstance, and keep an application-level reference to it. At certain points during this application I want to call methods...

DialogBox with value verifications

c#,.net,winforms
For my application which deals with graphics, I've made a little DialogBox to set: Max; Min; Major Step (of the scale); Minor Step. Here's a screen capture: I want to validate a few things before allowing the user to click Ok: Max >= Min MaxScale >= MinScale. But it's not...

how to avoid exe.manifest and exe.config in my build

.net,winforms
I am developing winform app. I want to use the Exe I get inside the \bin\Release to run my app. But each time I build the app I get two extra files with extensions exe.manifest and exe.config inside Release folder. If i run my exe file with out these files...

How to calculate values at textchanged event? [on hold]

c#,winforms
I have tried at textchanged event decimal a1 = Convert.ToDecimal(0.00); decimal b1 = Convert.ToDecimal(0.00); decimal c1 = Convert.ToDecimal(0.00); a1 = Convert.ToDecimal(txt_Advance.Text.Trim().ToString()); b1 = Convert.ToDecimal(txtTotal.Text.Trim().ToString()); c1 = b1 - a1; txt_Net.Text = c1.ToString(); This works only one time when I again changing value. It gives error of incorrect format at txt_Advance.text...

How can i display long units in MB and also displaying percentages progress in a progressBar?

c#,.net,winforms
I have this line: backgroundWorker1.ReportProgress((int)obj.BytesSent); BytesSent is a long var. I needed to cast it to (int) to report it. And now in the backgorund1 progresschanged event i want to display it as MB. For example 0.3MB 0.7MB 33MB instead displaying Bytes. private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) { toolStripStatusLabel2.Text...

How to handle different event handlers with same parent?

c#,winforms,dynamic,parent
The following program is actually not my project, but it makes it easier to understand what I want later in my real program. Here a .gif to see the current functionality: What I want? I want add a label total points. Which includes the points of the checkboxes and textboxes,...

Properly display list of custom objects in Windows Forms' Property Grid

c#,winforms,propertygrid,typeconverter
I'm trying to display the properties of my Wall class in a properties grid. Right now my wall class looks like this: [TypeConverter(typeof(ExpandableObjectConverter))] public class WallType { #region _private variables and Properties public string Name { get; set; } //Name of the wall to identify it. For the wall program,...

MVP in WinForms ( presenter & program.cs)

c#,winforms,mvp
I'm learning an MVP pattern and have the following issues: If I have one form(project MainForm), one model(project Model) and one presenter, should I create a new project for my presenter or it's ok to put it in MainForm project? 1)If presenter must be located in separate project, it obviously...

Remove axis line from chart c#

c#,winforms,charts
I want to remove axis line from chart in c#. I want to have only point there. How to do that? Here is a result Here is Code: public ChartBuilder(ref Chart chart, double minValue, double maxValue) { this.chart = chart; this.chart.Series.Clear(); chart.ChartAreas[0].AxisX.Minimum = minValue; chart.ChartAreas[0].AxisX.Maximum = maxValue; chart.ChartAreas[0].AxisY.Minimum = minValue;...

Using Invoke() to show Form from Threading.Time() thread

c#,.net,multithreading,winforms,.net-3.5
I have the following: public static Form1 MainForm = new Form1(); static ManualResetEvent _running = new ManualResetEvent(false); [MTAThread] private static void Main() { int startin = 60 - DateTime.Now.Second; var t = new System.Threading.Timer(o => Analyze(), null, startin*1000, 60000); _running.WaitOne(); } public static void Analyze() { Action a = new...

How do I get Visual Studio 2012 to generate code from a windows form design?

vb.net,winforms,visual-studio-2012
I am trying to add a simple windows form to my VB.Net project. I have used the designer to design the form how I want it with buttons, a text box and a Timer. The problem is when I try to view the code, there is only an empty class...

getting keyboard input in winform listbox

c#,winforms,keyevent
i am altering a program so that a listbox picks up keyboard input (number pad, D0-D9, letter keys) and edits properties of the currently selected listbox item based on the input. my problem is that there seems to be no functionality that can convert a key press into a letter....

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...

Dynamically Resizing Controls on Windows Forms

c#,winforms,layout
I has a winform which can be resize. I has 4 chart control in the form and sit side by side. When the form is in maximum size, the layout of each chart control is run out. I try to set the anchor style but i got no luck. How...

Getting Multi Rows in Database and transferring it in a multiline textbox in VB.net WinForms

database,vb.net,winforms,textbox
Here in my code, i have a database which has table of my applicants. As you will see in the code below, i want to get the number of rows from my command text and transfer it to the string "abc" Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As...

Form close event in visual studio c#

c#,winforms,visual-studio
I had an problem with my application closing in c#. When I hit the close button it display twice or more times the message box. What should I do? private void home_FormClosed(object sender, FormClosedEventArgs e) { DialogResult dialog = MessageBox.Show("Are you sure you want to really exit ? ", "Exit",...

C# Treeview keys fullpath

c#,winforms,treeview
There is this treeview with nodes added like so: tree.Nodes.Add("key", "DisplayText"); tree.Nodes["key"].Nodes.Add("key2", "DisplayText2); I want to obtain the full path of the currently selected node, but I want the path of keys not the path of display text. If the second node is selected, the tree.FullPath property will return the...

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...

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...

Add default item to ComboBox while binding data with DataSet - WinForm

c#,.net,winforms,combobox
My Code to Bind ComboBox in windows forms is like this ddlUsers.DataSource = dsUsers.Tables[0]; ddlUsers.ValueMember = "userID"; ddlUsers.DisplayMember = "Username"; I want to add a deafult Item as first element to this ComboBox, I have tried something like this ddlUsers.Items.Insert(0, "-Select a user-"); But it throws an error like this....

Value cannot be null when deserializing JSON

c#,winforms,json.net
I have a db table which has column in which content is stored in JSON format, I am retrieving JSON but I am getting this error. Value cannot be null Here is my code snippet. var stuff = (JObject)JsonConvert.DeserializeObject(commentId); string name = stuff["Name"].Value<string>(); string email = stuff["Email"].Value<string>(); string company =...

How to use XDocument to get attributes and add them to a List

c#,xml,winforms,list
I am trying to load data from an XML file and add it to a List. The XML file looks like this: and this is my code: public void LoadPayments(List<List<string>> list1, List<List<string>> list2) { try { if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RentData.xml"))) { int count = 0; XDocument doc; using (var reader =...

How to add multiple labels to a winform c#

c#,winforms
Issue I have a simple ui, where user enters a value click on the "ok" button, the SubmitDateHandler click handler should then insert a label to the form with the value from the textbox. Then when this is repeated again, Add another label underneath the existing label. how to dynamically...

Execute simple Logic without “locking” the UI

c#,winforms
I have a dialog with some txb's and a button. When this button is clicked I want to change the button's Text, disable the button, start some Logic and then close the Window. That logic has no return, it just sets a static variable. But it can take a minute...

C# Can Not Access public member of Form from Parent Class

c#,winforms,applicationcontext
I am trying to add an event handler in a Class that refers to an event of a Form Control which is instantiated within that Class. All classes exist within the same namespace. The program is based on an ApplicationContext forms application. Within static void Main() in Program.cs CustomApplicationContext applicationContext...

Move windows form from a picturebox in C#

c#,.net,winforms,picturebox
I have a windows form without any border. So i added a picture box and i want the whole form to be moved when that picture box is clicked. public const int WM_NCLBUTTONDOWN = 0xA1; public const int HT_CAPTION = 0x2; [DllImportAttribute("user32.dll")] public static extern int SendMessage(IntPtr hWnd, int Msg,...

winforms, form has been shown, event handler [closed]

c#,winforms,events
I need to run certain code each time after form has been shown by from.Show(). I tried form_Activated(), form_Loaded(), form.Shown() ... nothing works how I want, it only runs once, the first time. Is there a simple way how to do that? Thank you.

Excel CustomTaskPane with WebBrowser control - keyboard/focus issues

c#,excel,winforms,excel-2010,vsto
I am having this exact issue https://social.msdn.microsoft.com/Forums/vstudio/en-US/e417e686-032c-4324-b778-fef66c7687cd/excel-customtaskpane-with-webbrowser-control-keyboardfocus-issues?forum=vsto Also mentioned here https://connect.microsoft.com/VisualStudio/feedback/details/521465/the-focus-issue-between-excel-cells-and-excel-customtaskpane-with-webbrowser-control I am writing an Excel 2010 plugin using Visual Studio Professional 2013. I've created a simple CustomTaskPane with a System.Windows.Forms.WebBrowser child filing...

How to ask the GUI thread to create objects?

c#,multithreading,winforms,async-await
I've got the following program flow in my Windows Forms application (WPF is not a viable option unfortunately): The GUI Thread creates a splash screen and a pretty empty main window, both inheriting Form. The splash screen is shown and given to Application.Run(). The splash screen will send an event...

Is there a way to create a common event?

c#,winforms
I am creating a type of logging mechanism. The task is to log each button click and check which functionality is used the most in a production environment. I was wondering if there is a way to create an event for all button clicks in my application including referenced projects....

Show paused Timer value in Label

c#,winforms,timer
I've created a C# windows form application that uses a timer to clear the input boxes every 5 minutes. There is a label called lblTime that displays the amount of time elapsed at any given point while the application is open. I would like to be able to disable or...

How to make inherited form full screen [on hold]

c#,winforms
I am having some trouble trying to get a windows form project go full screen and to hide the taskbar. I am inheriting forms from a master form. When I add the following code it still shows the task bar at the bottom. this.TopMost = true; this.FormBorderStyle = FormBorderStyle.None; this.WindowState...

communicationg to device using cdc usb protocol in c# windows application

winforms,c#-4.0,usb,serial-communication,cdc
I need help to create a c# application for usb communication using cdc protocol. My application is communicating to device by using by using usb communication protocol.Can somebody give me a sample application in c# showing sending and receiving of data using "Communication Device Class" usb protocol. Thanks in advance...

Winforms - how to print the whole of a form, including unseen parts?

c#,winforms,printing
I have a windows forms project written in C#. The main form has a TabControl on it and there is a requirement for one of the users to be able to print one of the TabPages. The form is very long and I use a vertical scroll bar. The whole...

Need overlapping button in round cornered Winform

winforms,rounded-corners
Need a quick suggestion for styling a WinForm. I made it with rounded corners even when re-sized. Now trying to add a close button with a image (ControlBox=false), overlapping or clipped to top right corner. This is what I could end with. But I wish to make it more like...

passing combobox values between forms

c#,winforms
Fairly simple problem i know its something simple i'm doing wrong but i need another set of eyes to help me out here. I have 2 forms/classes and i want to pass the combobox.selectedtext from form, to a string in form2. public partial class Form1 { public Form1() { InitializeComponent();...

Adding GUI controls dynamically

c#,.net,winforms,user-interface
I am facing a problem adding a panel, two buttons in a scrollable (through another panel) group box. I am not good in adding UI elements without the designer, so naturally, I've got a cluttered interface that doesn't work the way intended. Here is the code: private void client_DownloadFileCompleted(object sender,...

how to remove a row from datatable

c#,winforms,datatable
I'm trying to remove/delete 1 row from datatable which has 100 rows like this: Form1.dt.Rows[i].Delete(); Form1.dt.AcceptChanges(); but further down when i get the count of the rows of the table like : int rc = Form1.dt.Rows.Count; the rc still returns 100! does Form1.dt.Rows[i].Delete(); clear the row and leave it empty...

Save values from select query then use them in update query SQL Server CE

c#,winforms,sql-server-ce
I have a Winforms application with a SQL Server CE 3.5 database. I want to do an UPDATE query and for this I need a SELECT query. Here's what I wrote: string command1 = "SELECT Column1, Column2, Column3 FROM Table1"; string command2 = "UPDATE Table2 SET Column2 = @var2, Column3...

Managing per form ObjectContext lifetime

c#,winforms,entity-framework,orm
For ORMs like EF and NHibernate, multiple places suggest using "context per method" (or per request, per transaction) for web apps and services and using "context per form" for thick clients like WinForms and WPF. In C#, resource disposal with context per method is clean and clear with a using...

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...

Why when adding items to combobox it's adding the same item many times?

c#,.net,winforms
In the top of form1: public class ComboboxItem { public string Text { get; set; } public object Value { get; set; } public override string ToString() { return Text; } } List<string> results = new List<string>(); Then: ComboboxItem item = new ComboboxItem(); var result = videoCatagories.Execute(); for (int i...

Notify winforms application by Sql Server database changes

c#,.net,sql-server,winforms,sqldependency
I created a Sql server database, in which I added a table named user. Then I executed this script ALTER DATABASE [TestNotification] SET ENABLE_BROKER I'd like to use SqlDependency class to notify a winforms application when the user table were changed. namespace Watcher { public partial class Form1 : Form...

How to create a folder that contains the current date and time instead of name

winforms,visual-studio-2013,c++-cli
I use C++ Windows Form application in Visual Studio 2013 for one project. I wonder how to create a folder that contains the current date and time instead of name? It is possible to make such folder?? DirectoryInfo^ directory = Directory::CreateDirectory("C:\Users\Desktop\" + ??); ...

Highlight specific string in listbox

c#,winforms
I am trying to highlight current playing song in listbox. I got the currentItem of playlist. But it does not get selected because index is always -1. public void _open_Click_1(object sender, EventArgs e) { _playList.Items.Clear(); string[] filenames = { }; _openFile.Multiselect = true; _openFile.ShowDialog(); var l1 = _playa.playlistCollection.newPlaylist("PlayList"); foreach (var...

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 do I make another form open when I click a button?

c#,winforms
I've made another form in my project, and i wanted to know how to open inside of another form? Can you please help me! Here is the code that I've got so far: private void optionsToolStripMenuItem_Click(object sender, EventArgs e) { ??? } Help me, I'm a beginner In c#...

CEFSharp Winforms display a loadin message while the website loads?

winforms,chromium-embedded,cefsharp
Am using Cefsharp 39.0.0 to load a webpage inside a winform. Now while the page loads the form is blank. How do I show a loading gif? public Browser() { InitializeComponent(); string clientURL = "www.imdb.com"; ChromiumWebBrowser browser = new ChromiumWebBrowser(clientURL); browser.Dock = DockStyle.Fill; toolStripContainer.ContentPanel.Controls.Add(browser); browser.RegisterJsObject("camera", new Camera()); } I looked...

How can i put formclosing event in Button

c#,winforms
i make this button btnCallenge and i want if the person click on it the form can't be closed if he try to close it i want the form cant be closed if the user click on chellange button public void btnChallenge_Click(object sender, EventArgs e) { } private void Form1_FormClosing(object...

Validating currency allows more than two decimal places [duplicate]

c#,winforms,validation,currency,tryparse
This question already has an answer here: Find number of decimal places in decimal value regardless of culture 8 answers Situation: I'm writing a Winforms app using C# in VS2013 with .NET4.0. Some cells in a datagridview need to be validated as correctly formatted UK currency values. The dgv...

c# winform to inspect an object during runtime

c#,.net,winforms
I want to display the public Property/Values of an arbitrary object during runtime in a GUI. Is there a winform which allows the user to view the content of any object like in debug mode? The object will hold many Dictionaries > and it would be nice to be able...

Application is missing required files

c#,.net,windows,winforms,sharpdevelop
Pic of Error: http://s23.postimg.org/7uj6qcxtn/9708083373e57a9ec91e4296e302f88e.png Cannot Download the Application. The Application is missing required Files. Contact Application Vendor For Assistance. So I'm building a windows form application using SharpDevelop 5.2 and I'm trying to make a standalone/version someone else would be able to use on another machine. In sharpdevelop (and visual...

How can i get list of my youtube videos from youtube?

c#,.net,winforms,youtube,youtube-api
I installed the google api 3 and the OAuth2. And i tried the google develope example: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Google.GData.Client; using Google.GData.Extensions; using Google.GData.YouTube; using Google.GData.Extensions.MediaRss; using Google.YouTube; namespace Youtube_Manager { public partial class...

Adding data to DBF file adds column _NullFlags

c#,winforms,oledb,dbf
Im currently working on a program that gets information from a sql database and creates a .DBF that has the information in there. I got it to the point where it makes the file and adds the columns/rows. But every time I run it, it adds a column named _NullFlags...

How to get the range of a specific word in Word Document using Word Interop

c#,winforms,ms-word,word-interop
I am creating a C# program that inserts a table inside a word document. Now, I need to insert a table in a certain position in different word documents. All word documents/templates I have has the word <table> in it where I want to insert the table. For me to...

Trouble creating DWORD in LocalMachine registry field with C# WinForms

c#,winforms,registry
I am trying to create a DWORD in the LocalMachine registry field using a WinForms (C#) application. No errors are raised, but the entry is never created. RegistryKey registryKey; registryKey = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\InetStp\Configuration"); registryKey.SetValue("MaxWebConfigFileSizeInKB", 512, RegistryValueKind.DWord); Any ideas? ...

Is it possible to login from a winforms application to a website which uses spring security?

java,c#,winforms,spring-mvc,spring-security
I want to call a web service from my winforms application. My application is written on c# and the webservice is secured using spring security. Is it possible to login to the website and call that web service?. If it is possible how to do that?...

KeyDown Event is not being fired

c#,winforms,events
I have added on top of my form PictureBox & Panel and docked them to the form, and I have registered the KeyDown event, but it's not firing, why is that if the Form is the Container for both Controls?

Share config between UI and service

c#,winforms
Is there a way to deserialize user.config in a different assembly? I need a form bound to Properties.Settings and then a service accessing these settings. I've tried ConfigurationManager which loads the config fine, but there seems to be some kind of protection keeping the userSettings section out of my reach....

Why i'm getting exception StackOverFlowException ? And how to solve it?

c#,.net,winforms
I added a new form in form1 i have a button click event: private void button1_Click(object sender, EventArgs e) { UploadTestingForum utf = new UploadTestingForum(); utf.Show(); } And the new form code i took from example here: https://github.com/youtube/api-samples/blob/master/dotnet/UploadVideo.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq;...

How to make if statement that checks if multple listBoxes are empty or not?

c#,winforms,if-statement,listbox
How do I make an if statement that asks if multiple listBoxes are empty or not? This is what I have so far...is it possible to combine it into one single if statement? if (listBoxEmails.Items.Count < 1) { //Perform action } if (listBoxWebsites.Items.Count < 1) { //Perform action } if...

OpenFileDialog always display the first file opened

c#,winforms
I'm trying to use OpenFileDialog to open multiple files and play them in a winforms media player COM component. Everything seem to work, though in the listbox I see the first file name times number of files selected. _playList.Items.Clear(); string[] filenames = { }; _openFile.Multiselect = true; _openFile.ShowDialog(); //filenames =...

One button with 2 actions

winforms,powershell,button,click,action
I did try to make 1 button that makes 2 actions: one on the 1st press (click), the other on the 2nd press (click), and repeat. However, none of my approaches worked for me, so I made 2nd button to make 2nd action, but I would really like to have...

How do I keep previously painted objects from disappearing when a new one is creating in a Windows Form Application?

c#,winforms
My problem is that within my Windows Form Application, I want to draw an Ellipse everytime the mouse is clicked within a specific picture box, and I want the previously drawn ellipses to remain present in the picture box. In its current state, once the mouse is clicked, the previously...

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...

C# Windows Form Application - value not printing in textbox for each time

c#,winforms,textbox,windows-forms-designer,form-control
Value not printing in textbox for each time.. Iam able to see last value only (10) in textbox. private void button1_Click(object sender, EventArgs e) { for(int i = 0; i<=10; i++) { textBox1.Text = i.ToString(); Thread.Sleep(100); } } ...

Unexpected token while parsing Facebook RSS

c#,facebook,winforms,rss,.net-4.5
I'm trying to parse the facebook RSS but none of them seems to work. Every method I've tried so far result in a different exception. I changed the format to format=atom10. I ended up with below code void loadRSS3() { string url = "https://www.facebook.com/feeds/notifications.php?id=XXXX&viewer=XXXX&key=XXXX&format=atom10"; var req = (HttpWebRequest)WebRequest.Create(url); req.Method =...

Custom drawing using System.Windows.Forms.BorderStyle?

c#,.net,vb.net,winforms,custom-controls
I want to mimick drawing of default border based on value of property BorderStyle. Instead of single border around the control, my control is visualised as four adjacent custom-drawn boxes (2×2), each having standard border drawn individually. So for example, if Control.Border is set to FixedSingle value I want to...

Application.Run(form) how to receive messages from the “form” c#

c#,winforms,.net-3.5
I am stuck on understanding how after starting the message loop with Application.Run(Form) i can receive back data from the internal app. My question is, How can I retrieve messages, objects, strings, etc? Basically I want that my internal application to send back an object to the main winform to...

How do I prevent any button click events from queuing until the event handle is finished with the first call

c#,winforms,event-handling
I want to prevent a button click from queuing. In testing I have a Form, a Button and in the Code-Behind I have the event handler: private void button1_Click(object sender, EventArgs e) { if (_codeRunning) return; _codeRunning = true; //Application.DoEvents(); //button1.Enabled = false; _click ++; Debug.WriteLine("Click Number: " + _click);...

How to change background Color of label full length when Mouse Hover in c#

c#,winforms
I can't Select label back Ground color Mouse Hover event in full length,only can select The Word length I would like to get log out background same like username background as full width private void label5_MouseHover(object sender, EventArgs e) { this.LblChange.BackgroundImage = null; this.LblChange.BackgroundImage = global::Flex.Properties.Resources.Mail1; this.LblChange.BackColor = Color.Blue; this.LblChange.BackgroundImageLayout...

Dialog Form Closes After Error

c#,winforms
Calling the Subform: using (Form2 addEmp = new Form2()) { DialogResult dr = new DialogResult (); addEmp.FormBorderStyle = FormBorderStyle.FixedDialog; dr = addEmp.ShowDialog(); if (dr == DialogResult.OK) { retrive = addEmp.GetEmployee; addtoTextFileCombo(retrive); } } private void btnAdd_Click(object sender, EventArgs e) { try { iD++; this.GetEmployee = new Employee(iD, txtFirstName.Text, txtLastName.Text, txtEmail.Text);...