winforms

Drawing Items in a Listbox

Assume I have a Listbox with two types of objects in it, either a String, or a custom class called "Label". When I'm drawing the items in the listbox, is there a way to determine whether to cast e as a string or "label"? The functionality I'm looking for is so that the Strings show up as one color, and the Labels show up as another. (P...

ObjectDisposedException when Multiple Forms Are Open

My C# Winform application encounters the situation where it cannot access a disposed object. The disposed object is a form (frmQuiz) that is opened from a button on the login form. The Situation: My application typically has two or three forms open at the same time. The Program.cs file runs form frmLoginBackground, which is just a s...

Help Desk ticket system: Windows app vs web app

I want to create a small helpdesk ticket control system at work, that would allow users to enter a help request ticket; these tickets would then be assigned to a technician to work on, and the technician would mark it as "FINISHED" after the job is done. The requesting user would then be able to confirm and "CLOSE" the ticket, so that a ...

Integrating a WPF control in WinForms without allowing access to other WPF controls?

I need the DocumentViewer WPF control (for XPS files) in a Windows Form application. This is actually simple, but I'm not allowed to link in WPF assemblies. My boss' reasoning is that people will start using WPF controls which are incompatible with some of our software. I can't change any of this; it has to be XPS and cannot bring in mor...

How to add MenuItems when MDI children are merging their menus

I have a menu with a 'Windows' list that contains all mdi children thanks to the MdiList property. However there are other windows that are not inside the MDI container which I want to list in the menu. I can easily add them to the menu, but a problem arises when one of the MDI children has a menu. The menus are merged, but the menu b...

Combo Box Question

I have added items in a combo box using datatable and rows. First it returned the value, and now it's returning dataRow. I don't know the reason why it's returning like that. Can anyone help? string selectedValue = cbx_language.Text.ToString(); ...

How to stop a comboBox's selectedIndexChanged event from firing when the form loads

I have a form with a ComboBox that provides a dropdownlist. On the comboBox's SelectedIndexChanged event, am running some code, but i don't want that code to run when the form loads. Unfortunately, when i load the form (before i make a selection in the combobox), SelectedIndexChanged of the combobox fires ( i think when the combobox is d...

Control.Parent = null

I have my own control derived from Windows.Forms.Control and I am checking the Parent.BackColor inside the overrided of OnHandleCreated() method. At desing-time the Parent property first returns null, then - after form is completely loaded - returns the real parent window: the form itself. We need to draw part of the custom control with...

Show an animation during a longer process on a windows form

I have a windows forms dialog, which does something for longer time after clicking a button. Because this takes while, I want to show an animation on the dialog (an anmiated gif, avi or whatever). How can I achive this. Do i need an own thread for this (I have no experiences with threads)? Can you provide me a code snippet how to achieve...

How do I make an custom drawn resizable container?

I have a WinForms gui application which has a number of areas to it which I'd like to custom-draw some graphics. These areas would contain controls and be resizeable. I'm currently thinking of inheriting from a TableLayoutPanel and handling onpaint messages. Does this sound like a good way to go or are there other/better options? ...

Determine if a Form from another project is open

My c# WinForm solution contains several projects including an Admin project with several forms and a User project with several forms. I want my user forms to behave differently when specific admin forms are open. How can the user forms tell when admin forms are open? All forms have no 'this.Text' value (all these values are null). W...

How do I create an installer for a .NET winforms application so it doesn't need to install?

I'm responsible for an in-house application that is deployed as a ClickOnce application. We run into issues reasonably frequently when a developer runs the tool after a a several new versions have been published (due to new features, bug fixes or whatever) and the output of the tool no longer conforms to what the developer is expecting...

C# Synchronization

I have a question about synchronisation: private void ProcessStuff(Task sometask, Form progressform) { if (sometask.foo == "A") DoStuff(); //This one is SYNchronous else { ThirdPartyObject Q = new ThirdPartyObject(); Q.ProgessChanged += delegate(object sender, ProgressChangedEventArgs e) { ...

rebind my dataGridView

Hello My Project include dataGridView Control, and i change the property: gridview1.columns.DataPropertyName at run time Now, i need rebind my gridView, how i do this. in asp.net is simple gridView1.DataBind(), bun how in c#. i try to do this: this.gridview1.DataSource = "MyDataSource" this.gridview1.refresh() and it's not working....

RichTextBox equivalent of TextBox.AcceptsReturn

I am switching several TextBoxes out for RichTextBoxes to gain some of the cool features. I had my TextBoxes configured to AcceptReturn so that the enter key will create a new line, rather than leave the control. The RichTextBox does not seem to have this feature. Is there a simple way to do this, or do I have to capture all keypresses...

Catching a Contained Control's Mouse Events in a UserControl

I have a UserControl that contains another UserControl. I'd like the containing control to be able to handle any mouse events that happen over the contained control's area. What's the easiest way to do this? Changing code for the contained control is possible, but only as a last resort. The contained control has a window that is contr...

Drawing on a panel in the constructor of a form

I have the following sample code, which I expect to color the panel on the form red as soon as it loads: public partial class Form1 : Form { public Form1() { InitializeComponent(); drawstuff(); } public void drawstuff() { using (Graphics g = panel1.CreateGraphics()) { g.C...

Transition of images in Windows Forms Picture box

Hi, I'm new to Windows Forms, in my project, i need to change the image in the picture box at runtime. I'm able to do that with the help of a timer. The picture just gets changed. Is it possible to do some transitions when image changes, for example fade in, fade out, blur etc.. If possible could some one please let me know how to do it...

Why doesn't Graphics::DrawImage stretch images as expected?

I'm making an overloaded TableLayoutPanel which draws some fancy borders, but for some reason the call to Graphics::DrawImage isn't working as expected. It seems to fade out my 1x10 pixel source image when I stretch it: This is the function which does the rendering: void GTableLayoutPanel::RenderSides(Graphics^ g, array<Drawing::Imag...

How can I make a windows application that doesn't have a square form shape?

I want to make an application that is similar to the World of warcraft launcher. My main concern is to not have a square windows form with the typical close buttons, but a custom shape. How can I achieve this with C# and the .NET framework? ...