winforms

c# cross-thread error with UserControls

Here is my situation: I instantiated a c# usercontrol on a main thread, but it is not added to the form. //global declaration usercontrol1 datacontrol; constructor() { ....... datacontrol = new usercontrol1(); ........ } I then have an asyhcnronous background thread that fires an event that is handled by the instantiated data...

How do I create a secondary message loop in vb.net?

I've got an app working semi-background stuff in the GUI thread. Another thread won't work and a timer won't work. But I want the app to be responsive while I'm going my 'background' work. I cound use application.doevents - but that gives me 3 bad choices: loop with no sleeps - end peg an entire CPU (my task waits on stuff besides cal...

change the color of a char

Hi all How can I change the color of a char in a string using C#? for ex. MIND, make D to be red and the rest remain black. I'm using a WINFORMS and I try to display it in a textbox, I can Use richtextbox as well. ...

C# form - controls losing dock state during threaded operation

I have a form with a menu strip, a status strip, and a main split container (which itself contains other split containers, tree views, tab control, etc). Occasionally (fairly frequently, actually), the application will stop resizing controls within the main form (usually during or right after a background thread operation to retrieve da...

C# winForm Basics Combobox

hey all, i've built a ComboBox that gets manually items like this: var newitem = new { fullname =c.Company+" "+ c.FirstName + " " + c.LastName, custId = c.CustomerID }; c_dropCustomers.Items.Add(newitem); later on on combo Selection event, i would want to get out the custId (The Value) only but i dont know how to ...

What are the technical difference between .Net desktop application and web applications?

I have just started learning C#. Can anyone explain the technical differences between a .Net desktop application and a web application?. I mean for example, if I have a simple HelloWorld application using a WinForm, what are the steps required to change that into a HelloWorld web application? ...

Cannot get a FlowLayoutPanel to Expand

I have a FlowLayoutPanel, and I am constantly adding controls to it. They all work, yeah, life is wonderful. But when the container hits its boundaries, it just stays the same size. Now, I realize I can make it have scrollbars, but this is not what I desire. I want the FlowLayoutPanel to grow in size based on the controls added. Any ide...

Entity Framework filter nav property with Self Tracking Entities

I'm using Self Tracking Entities and have a scenario where I have an entity that represents a table that we'll call table A. A is a parent to another table B which is also represented as an entity. On my WinForm I have 3 different binding sources that each represent different types of records from table B but all are children of table A....

How to monitor whenever a cell value is changed in DataGridView?

This is a winform C# question. I have a customized DataGridView control inherited from the standard DataGridView class. I want to monitor the case whenever a cell is added to the grid, a cell value is changed in the grid. I have no idea how to do this. The DataBindingCompleted event is helpless in cell/row/column level. The CellValueCh...

How can one get a ContextMenuStrip to show on left click of a NotifyIcon?

I have a ContextMenuStrip assigned to a NotifyIcon and this works with the right click fine. How may I wire up the mouse-click event to tell the NotifyIcon to show its ContextMenuStrip? private void taskbarIcon_MouseClick(object sender, MouseEventArgs e) { switch (e.Button) { case MouseButtons.Left: // What ...

Generate auto increment in textbox

How do I get to increment a textbox content on page load in such a way that if i run my application and if the form is getting loaded the value should be 0000001 and if i load the same form again with out closing my application it should be 0000002. If i close my application and run again the value should be 0000001 ...

Would it make sense to have two GUI threads for two independent forms?

At work we've got a very CPU-intensive Windows Forms application. It's running on a server with 24 cores. As the Windows Forms model involves a single GUI thread processing a message pump, it seems that a rich, complex GUI is not making good use of the capabilities of the system. Am I wrong in saying this? So my coworkers were discussi...

Notify / Check if database content has changed

Is it possible to know when and if the contents of certain tables in a database has changed? I' builting an multiuser app, and I want to notify the user if somebody else modified any relevant data. I'm using an Oracle 10g database and an .NET WinForms app. Thanks! ...

Winforms Updating UI Asynchronously Pattern - Need to Generalize

Setup: Main MDI form with a progress bar and a label. Code in Main form. public delegate void UpdateMainProgressDelegate(string message, bool isProgressBarStopped); private void UpdateMainProgress(string message, bool isProgressBarStopped) { // make sure we are running on the right thread t...

How to handle Right mouse click event for a Tree view

I would like to have an option as rename File if i select on a file of the treeview. If i right click the mouse i would like to have an option as Rename file and if i select that i would like to able to rename it.. ...

.Net 3.5 Winforms Basic Dialog with Label Autosize for custom text contents

I want a form containing: +----------------------------------------+ | Dialog Title X| +----------------------------------------+ +----------------------------------------+ |icon | | |32x32px| One-line label (Heading) | | +--------------------------------+ | | ...

Interacting winform app with excel

I have a c# winform app that shows trading info to users. What we want to do is be able to open an excel sheet and have it request the data from the application. In return application gives data back to excel. After that if the data is updated in application, it also gets reflected in excel. In other words, we make excel display what app...

Whats the difference between these methods for closing my application?

Basically I have a main form which upon loading, opens a child form for logging in the user. When they cancel or close this login form, I need to close the whole application. But there seems to be a few different ways to close a C# program: Application.Exit(); Application.ExitThread(); Environment.Exit(1); Process.GetCurrentProcess()....

Disabled menu items in Winforms still show subitems

If I create a menu with two items (say "Item1" and "Item2" and then create two subitems under each one (1A, 1B, 2A and 2B), and then disable Item1, I'd expect that 1A and 1B wouldn't show. And, indeed, if I move onto Item1 they don't. Unless I then move on to Item2, wait for 2A and 2B to show, and then move back to Item1. At which poi...

ListView SelectedIndexChanged Event no Selected Items problem

I have a small C# 3.5 WinForms app I am working on that grabs the event log names from a server into a listview. When one of those items is selected, another listview is populated with the event log entries from the selected event log using the SelectedIndexChanged event by grabbing the text property of the 1st item in the SelectedItems...