winforms

Where do I instantiate my Objects in CRUD n-Tiered WinForm App?

Say I have a WinForm CRUD(like) application. I want to follow best practices on this so I try and make it follow OOP and a n-Tiered design. Unfortunately I am familar with the words but not the practice of them. So lets go with the following example: My CaseNote program. I have a tabbed application where you go to the search tab t...

How to invoke with action?

Hello, I always set the modifiers on my form to private,I don't like internal nor public. Till now I used to Invoke like this: public string Addtext { if(InvokeRequired) { Invoke((MethodInvoker)delegate { textbox.text = value; }); } else textbox.text = value; } But addi...

Exporting ReportViewer to Excel - Line width variation

I am creating reports using the Microsoft ReportViewer control. I am encountering some formatting issues when exporting the reports into Excel. The problem is that I am specifying a line width of 1pt in ReportViewer, which is the smallest line possible (or is it?). When the export is done, the line widths in Excel are all thick bor...

Drawing ListViewItem exceed VisibleClipBounds

I'm trying to manually draw ListViewItems on a Custom UserControl. The control itself is a wrapper around a ListView stored as a private member on the class. There is a DrawListViewItemEventHandler attached to allow manual drawing for these items, and for the most part this seems to work. The problem I have is where the text for the Lis...

Field Validation For An IP Address

I am trying to prevent a user from entering anything into a particular textbox aside from a number or a period in C#. The textbox is supposed to contain an IP address. I have it working such that non-numeric entries are prevented, however I can't seem to get it to allow a period to be entered. How might I accomplish this? private vo...

ListView ItemChecked event

I have a ListView where each item has a checkbox. Initially there are no events attached and I set the state of the checkboxes programatically. After this I attach an ItemCheckedEventHandler and the event handler fires for each of the events that occurred before the handler was attached. Is there a way that I can clear the event queue...

Handing exception in BLL and return to client (either winforms or webforms)?

Hi I am looking for the best way to do exception handling, for example.. when an error occurs in the business logic layer, is the best way to stop the METHOD using a catch and return an EVENT to the presentation layer? What should this event contain? Or should i always BUBBLE up exceptions and handle them in the presentation layer? ...

Windows Forms TreeView always selects a node on focus

The TreeView in Windows Forms always seems to want a node selected when it regains focus. If I have no nodes selected, and that treeview gains focus, I'll get an AfterSelect event with the first node selected, even though I didn't select it using the keyboard, mouse, or programmatically. The only workaround I can find is to check if th...

How to copy items of listbox to items of a combobox?

I want to copy all the items in a listbox to items of a combobox on runtime so need help ...

How to implement 'undo' operation in .net windows application?

Assume that, a win form has certain input fields and user enters/re-enters some data. How to retain data previously entered by 'undo' operation? Just I want to know the best way to accomplish it. ...

How to create IDLE -like functionality to WinForms application

Hi, I'd like to add "IDLE-like functionality" to C# WinForms application, but I don't quite have an idea how to do that and couldn't find anything useful with Google. So basically I want interactive command line interface, where user could enter some Python code and execute it (not just expressions, should be possible to define new fun...

How do options forms work?

How do winforms options systems work? I've seen one article which implements the functionality via xml serialisation. Is it possible to implement this functionality via a class using static or constant variables? I can't quite remember, but do consts/static variables maintain state even when the application is closed? Of course, I know...

Tooltips for CheckedListBox items?

Is there a straighforward way to set additional text to appear in a tooltip when a user's mouse is held over an item in a CheckedListBox? What I would expect to be able to do in code is: uiChkLstTables.DisplayOnHoverMember = "DisplayOnHoverProperty"; //Property contains extended details Can anyone point me in the right direction to d...

Reflecting changes to DataTable in bound Label

Hi, I have a column of a DataTable bound to a Label (via a BindingSource). If I make a change to the current row thus row["Column Name"] = "New Value"; the change is not reflected in the bound label unless I also do bindingSource.ResetCurrentItem(); However, if I wrap the change to the column in a Begin/EndEdit as follows row.Be...

windows forms: textbox with history

hello, does anyone know about a windows forms control that acts like the address bar of a browser? it is just like a textbox, but to the right there is a dropdown menu that shows the history of previously entered text. thanks a lot! ...

Winforms Creating Dropdown style panel

Hi I am attempting to create my own custom Autocomplete style dropdown control in c# .net2.0. For speed of development I have built my control as a UserControl but have hit on an issue of doing it this way. When the custom drawn dropdown gets drawn I have to resize the UserControl area to be able to display the list of options. Ideal...

What's the difference between Control.Select() and Control.Focus()?

In WinForms, to set focus to a specific control, I always seem to wind up calling Control.Select() and Control.Focus() to get it to work. What is the difference, and is this the correct approach? ...

C# /windows forms: linking trackbar and textfield with a factor

hello, linking a trackbar and a textfield is very easy in windows forms. it is like this: textBox.DataBindings.Add("Text", trackBar, "Value"); the problem is, that trackbars only allow for integer values but i want to have floating point values. so i usually just divide the value by 100, since on the trackbar the value is not directly ...

Trouble passing value array into an Object array

I am trying to pass an array of values into an array of a table object so that I can write them to the database. My database looks like this -> tblCaseNotes CaseNoteID | PersonId | etc, etc tblCaseNotesContactType rowguid | CaseNoteID | ContactTypeID tblMaintItems itemID | CategoryID The itemID from the Maint table is what is being w...

How to ensure that a winform closes in exactly X seconds

In my WinForms application, I need to pop up a little custom dialog that stays on the screen for X amount of seconds and then disappears. So I use a System.Threading.Timer to invoke the _dialog.Close() method once the appropriate amount of time has elapsed. This of course means that I have to do the whole "if InvokeRequired BeginInvoke...