winforms

How to get the caller winform

Hello, I have a winform that opens (ShowDialog) other winforms. Is there a way to get the first winform from the opened winform without passing it as a parameter or using a "public static" solution ? EDIT: Didn't notice that i'm in a user control, how can i get my form? Thanks in advance. ...

Collections for multiple component types

Can anyone answer a quick question for me? I'm working on a control that contains multiple types of subcontrol. This is so that it can represent a heirachial list. --Group-- --Company-- --Site-- --Group-- Due to the increasing complexity I'm looking at the posssibility of using collections. I found an article on code project w...

open a modal form from my usercontrol

I have a usercontrol that opens a form. i want this form to open as modal having its parent the same parent of the usercontrol. is that possible? (all i need is that the form is open modal). when i tried (form.parent = this.parent) i got an error saying the form is a toplevel form. then i tried (form.toplevel=false; form.parent=this.pa...

How to add data to DataGridView

I'm having a Structure like X={ID="1", Name="XX", ID="2", Name="YY" }; How to dump this data to a DataGridView of two columns The gridView is like ID | Name Can we use LINQ to do this. I'm new to DataGridView Pleaese help me to do this.. Thanks in advance ...

Getting the currently needed width of a dataviewgrid

For C# and Windows Forms the actual needed width in pixels can be calculated as such: Edit: Using col.Visible instead of col.Displayed as per smirkingman's comment! public int getDisplayingWidth( DataGridView gv ) { int gvWidth = 0; if ( gv.RowHeadersVisible ) { gvWidth += gv.RowHeadersWidth; } if ( ( gv.S...

c# - Stop program execution incase of error

I have a winform application that can catch any number of possible errors. I have found though, that once a messagebox or some other method of displaying the error has been displayed (within a catch block), the program execution continues. How can I simply stop complete execution of the program in this event and simply just keep the fo...

C# progress bar doesn't show WinForm

What happens is when I click the button to run my code my win form locks up and my progress bar doesn't run. What am I doing wrong? foreach (string barcount in idit) { barcountmax++; } label2.Text = "Total entries: " + barcountmax; progressBar1.Minimum = 0; progressBar1.Maximum = barcountmax; ... foreach (string ids in idit)...

How could I emulate a visual analogue scale (VAS) in Winforms?

In Psychology, Visual Analogue Scales (VASs) are commonly used to collect subjective responses without overtly quantifying them. They don't have gradations; just end-points. The participant is asked to click a point on the line and the distance from the end is taken to be their response. In some cases, the location on the line is illustr...

C# Windows Listview Scrollbar

In windows forms ,how can I bring the default scroll bar inside the listview. Please refer image attached. ...

C# backgroundwork / progress bar not updating

string[] idit = File.ReadAllLines(textBox2.Text); foreach (string barcoutn in idit){ barcountmax++; } foreach (string ids in idit){ //do sql stuff barmovement++; bgw1.ReportProgress(barmovement); } private void bgw1_ProgressChanged(object sender, ProgressChangedEventArgs e){ progressBar1.Value = e.ProgressPerce...

populating textbox based on checkbox.checked value of numerous checkboxes

I have a groupbox which contains 10+ checkboxes. I would like to build a string that concatenates the Checkbox.Text of all the checkboxes which are checked. Of course anytime the checked state changes for any of the checkboxes it will need to rebuild the string. How can I go about doing this? Note: This needs to happen on the fly as c...

How to query a DataSet and set the result as a DataSource for some control? (C# winforms)

I'm digging in in my Microsoft Visual Studio Documentation and I found this article under C# Reference (ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/dv_csref/html/df01e266-5781-4aaa-80c4-67cf28ea093f.htm), It's about Interface Interface. Here's the example code: class SelectSample1 { static void Main() { //Crea...

Getting Application path during the installation

im deploying an application and during the installation after the user choose where to install the app i want to get that path , im in a custom action already but i dont know how to get the application path where its going to be installed ! its Windows Forms and im developing using Visual studio 2010 "C#". and im using the default depl...

How to properly implement a custom control that handles mnemonics?

I am implementing a custom control in WinForms. This control needs to respond to a mnemonic character, and the mnemonic needs to focus the next control in the tab order - like a Label control does. The ProcessMnemonic method is clearly the one to override. However, looking at how the Label control does it, for reference, shows that it r...

Is storing an object reference in a controls Tag property OK

I'm creating a group of form controls for each object in a list, is it OK to store a reference to the object in the controls Tag property? I'm doing this so I can have a generic Click event on the controls, so when they are clicked I can update a field in the object that they represent. So the click handler will look something like thi...

Event does not hook up correctly

Hi Folks Not sure if i will be able to formulate my question quite clear but let me try: So i've written a small piece of code which will give the user the option to select a desired status for his Office Communicator when his PC get locked ( by default it goes automatically on status "away" ) .So here it is the Windows Form wich is b...

c# calling back to main thread

Hi, I'm in a static class in a background thread , but i want to create a new GUI component, to do this i need the main thread of the application to executing the method. How can I do this? [note i dont think i can use InvokeRequired as its a static class not a gui] David ...

How to copy string of a particular cell of datagrid view by double click using c# winform?

I have this requierements that if a click a particular cell on datagrid view..it will copy the cell string and display on a textbox on the other form. This is my PseodoCode: Example: 1.Display Datagrid View Name | Family | Boar | Mamals | Snake | Reptile | 2.If Snake Clicked on Datagrid View. 3...

Detect Month changed in month calander C#

there is a MonthCalender in C# There is a 2 buttons to select the month Jan, Feb and so on.. Anyway I can detect that the user changed the month? ...

Visual Studio 2010 Mixed Mode .dll fix not working for me...

So I am getting the same exception as a lot of other people when I am trying to run an execute statement into my SQLite database in my Windows Forms project in Visual Studio 2010. The exception reads: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional confi...