winforms

.net tabcontrol tab sizes

I have a tab control where I'm using user painting to remove flickering. It's rendering fine in terms of flicker removal, but the tab widths are not right. There is a large amount of padding around the text that gets bigger as the length of the text on the tab increases. It's like the width of the tab is based on a font that is larger th...

Change the maximum width OR maximum height of a form in .net

I've been meaning to ask this question for a while. It appears that if I want to set a maximum width of a form then I have to set a maximum height as well. Is this right? If so, which of the multitude of variables do I use, in this situation, to set the maximum form height to the height of the window? Screen.PrimaryScreen.Bounds?, Sc...

itextsharp: pdfptable.writeselectedrows vb.net

can someone please show me documentation on this method? i have the following line: datatable.WriteSelectedRows(0, -1, document.LeftMargin, document.TopMargin, writer.DirectContent) and it doesnt seem to matter whether its topmargin or bottommargin, it puts it at the bottom of the page. ...

Windows Forms ComboBox problem

I have a combobox that goes out to the database to load it's content on clicking the dropdown arrow. if after the dropdown box is shown with data and I don't select anything, than the current value of the combobox is blown away. Inside my routine to load data, I tried saving the current value and restoring it back after the loading is do...

How to get the browser document canvas absolute position in C# and process handling?

Hi! I want to fetch the coordinates of the top-left corner of IE render canvas. I got a simple C# program working using win32.dll and I can fetch the whole window position. The tricky part is what's inside of it. Any ideas? Thanks in advance! Bruno ...

Benefits of using Inherit Forms Controls

I tryed to create new components from one base Windows Form, also I found difficulties when I worked with toolstrip components, for example : how to bind a datagrid.datasource on a child form using events from a button (clicks) on the parent toolstrip? I have to use some snippets on each child form for doing this, btw why? // btnSear...

how do I delay instantiation of the main form until responded to an event in a win forms app?

Some background: I get the following exception in my code below. ThreadStateException : ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment. The Main() method is marked with the [STAThread] attribute. The app is supposed to start up without a wi...

datagridview winform tag only brings back the first row value

I'm using visual studio 2008. I have a datagridview in a winform. I've bound to it using an object Private Sub LoadAllCampers() Dim Os As List(Of LE.Camper) = Nothing Dim Oc As New LE.Camper_Controller Os = Oc.GetCamperData(0) With Me.dgResults .DataSource = Os End With CamperBindingSource.DataSourc...

VB.NET: How to close and re-open a dialog in this case?

Hi, I'm developing a WinForms app in VB.NET, that handles sets of style data, and when the user clicks on another set's label, it prompts through a dialog "You are leaving this style preset to edit another one. keep changes on this one? [Yes] [No]" But, I'm facing the problem that, when the user clicks either option, and the dialog clos...

Change spacing of snaplines in Visual Studio 2008

Is it possible to change the amount of space snaplines put between controls in a WinForms project in Visual Studio 2008? For example, when I slide a textbox up to another textbox (one above the other), there's 6 pixels of space between the controls. I'd like there to be 5 pixels of space between them when they snap to each other. Than...

Holding shift+ctrl then release one each doesn't raise KeyUp event?

Hi, In my custom control, I override OnKeyUp event handler. When I press Ctrl key only, then lease it, the keyUp event fired, it's ok. When I press Shift key only, then lease it, the keyUp event fired, it's ok. But when I press both Ctr+Shift keys, then lease one by one, for example, holding Ctrl+shift first, then release Shift key w...

ListView Final Column Autosize creates scrollbar

Hi There, I am implementing a custom control which derives from ListView. I would like for the final column to fill the remaining space (Quite a common task), I have gone about this via overriding the OnResize method: protected override void OnResize(EventArgs e) { base.OnResize(e); if (Columns.Count == 0) ...

How to handle exceptions generated by DataSets?

Hi, DataSets in ADO.Net throw exceptions when there are constraint violations etc. It is easy to catch these exceptions in the WinForms UI Layer using DataGridView (using DataError event). However, I am unable to find a way to catch and handle these exceptions when using simple data bound (to datasets) controls such as textboxes. Any i...

GetDesktopWindow alternative when running as service

Hi, I am trying to test my WinForm app as part of the build (which runs as a service). I am using GetDesktopWindow and EnumChildWindows to find the controls I am interested in. This works perfectly when I run it in interactive session from the console, debugger, etc. but fails to find any control when run as part of the build. What can I...

How to add progressbar column in DataGridView in C# (Winforms)

Is there any way so that I add a progress bar column in datagridview. Actually I need to show the progress for each rows (task) in the datagridview. Let me know some sample code or links to acheive this functionality. ...

C# custom combobox sorting

Is it possible to have a custom sort/display order in a combox ? Say I want a special value "MasterValue" before all the others. ...

How can I ensure that a dynamically created Form will be a child window in the process tree of windows?

Hi, I am still trying to test my WinForm application, however some of the testing tools don't work because the custom dialog forms I dynamically create are not child windows in the window tree (in Win32 api sense). I am using Spy++ to browse and search for windows. If I use the Finder Tool on these forms, some of them are found as direc...

CSV import (variable fields)

I have to import a series of CSV files and place the records into an Access database. This, in itself, is not too much of an issue. The complication comes from the fact that the format of each CSV file is variable in that the number of fields may vary. The best way to think about this is that there are 80 master fields, and each CSV fi...

Got TextBox focus on Parent/Child form disposing

Hi all, I got a form with two textbox which show a child form OnClickEvent. I do work in the child form and when I dispose it, I'll like to give focus to the second main form's textbox. But it doesn't work, making txtBox2.Focus() and Dispose() on the child form as if the Dispose action lost the focus on main form. ...

How to bring a form to the current screen?

there is this FormStartPosition but that seems to be only for showing first time. Current screen is the one the mouse pointer is in. The form should appear top most. Setting the DesktopLocation on the form is too low level, I don't want to have to deal with all the possible desktop resolutions. It would be also nice that the form shows ...