winforms

List Box Update Issue

I have a ListBox of constant size 4 I can Add n number of ListBoxItems,Once size exceeds 4 I have enabled scroll bar, Problem:when scroll is enabled(more than 4 items), whenever i delete last item, there is a white patch in place of deleted Item. Patch goes off only when I touch the scroll bar. I tried ListBox.Invalidate(), But no u...

How do I convert a datatable to Excel sheets in windows forms using c#

Hi, I am working on Windows Forms application , c# I have three datatables. I want to save the first table in Sheet1 of an excel , second table in Sheet2 of the same excel and the third in the Sheet3. The names of these three sheets will remain the same, as Summary,Details and Retailers. Can anyone please let me know how do I do this. ...

Console.WriteLine does not show up in Output window

I have put some Console.WriteLine calls in to test, but they aren't appearing in the output box? public static ArrayList myDeliveries = new ArrayList(); public mainForm() { InitializeComponent(); } private void mainForm_Load(object sender, EventArgs e) { if (!File.Exists("../../MealDeliveries.txt")) ...

Disable the Excel export option when I generate a report via the ReportViewer

How can I disable the Excel export option when I generate a report, via the ReportViewer, in my winforms application? ADDITION: In particular, I want to hide the toolbar button that refers to Excel output/export task, and not .the one that handles to the pdf export option. ...

Dataset.ReadXml() - Invalid character in the given encoding

Hello all I have saved a dataset in the sql database in an xml column using the following code. XmlDataDocument dd = new XmlDataDocument(dataset); and passing this xml document as sql parameter using param.value = new XmlNodeReader(dd); The XML is like <NewDataSet><SubContractChangeOrders><AGCol>1</AGCol><SCO_x0020_Number>001</SC...

Parts of statusbar disappearing with IE BHO

I have a C# IE BHO in use for an internal company app that is adds a pane to the statusbar with SB_SETPARTS (it mitm's the SETPARTS call and inserts an element into the array) and then draws the controls by moving them from a hidden (in-process) form with SetParent() This technique works well but it causes other parts of the statusbar t...

referencing files that were included with vb.net solution

my application builds a pdf with images in the solution explorer i added a folder called pics and dropped all the images there when i run the program from my computer, there are no problems, but when i had a different user install the application they get this error: here's how i am including the image: Dim jpeg2 As Image = Image.G...

How can I use a meter-style progress bar?

In Vista/7, the Windows Explorer shell window makes use of a special kind of static progress bar to display hard drive space. With default styles, this bar is blue colored and non-animated. It also turns red colored when it gets close to being full (low disk space). Using messaging, I can tell the Windows Forms ProgressBar control to ...

How to initiate an uninstall of a ClickOnce app, from within the app?

Can I reliably initiate the un-installation of a ClickOnce app, from within the app? In other words, I want to give the user a big "Uninstall Me Now" button on one of the forms. When a user clicks the button, I want to start the windows uninstall process for this app, and perhaps close the app. Reason: We are dead-ending a ClickOn...

Create Lines around a guiding line using Miterjoin

Hi SO community! I am drawing graphs into a WinForms Picturebox. Now I am searching for a possibility to 'duplicate' a line (an array of points), so that the two resulting lines are positioned a fixed distance away from the original one. Like in this picture, I have the red line and want to get the black ones: I thought about just m...

C# winforms: A problem with sending an email cointaining the image background

Hi, I'm trying to figure out how to resolve the problem: I create the MailMessage object like that and send it: MailMessage mail = new MailMessage(); mail.From = new MailAddress("[email protected]"); mail.To.Add("[email protected]"); mail.Subject = "This is an email"; AlternateView plainView = Alt...

Form.ShowDialog() does not show form.

I've come across a situation where I try to run a simple line of code in a method Dim res As DialogResult = frmOptions.ShowDialog() but nothing happens. The dialog box will not appear. If I run this method from another location in the code it executes fine (i.e. displays the form in dialog mode and code executes fine thereafter). Hence...

How to use error provider at run time along with associating any control to validate

I am trying to create a Validation in a reusable fashion. Purpose: Make the validation control reusable. Error Provider should associate with control passed dynamically and can be set or cleared at run time. When user press OnClick event then all the controls gets validated with their own Error Providers. public bool IsFieldEmpty(re...

RichTextBox doesn't update caret position correctly

I have a handler consuming the keyDown event of a WinForms RTB, that has the following code: GetTextAtLoc(RTB->SelectionStart); // selects some text at the caret's position RTB->SelectedText = "SomeOfMyOwn"; GetTextAtLoc(RTB->SelectionStart); // selects the replacement string RTB->SelectionStart += RTB->SelectionLength - 1; While this...

How to cancel any event in winforms?

I want to cancel an event from within that function scope. Eg. I pressed button click event and on false validation, I want to cancel this event. Likewise i want to cancel other events also. How can i do this in C# ...

c# Validation approach

The scenario is like this: There are 4 controls, two drop downs, two date pickers and some validation rules. One is master drop down Depending upon the value in master drop down, some validation rule will be applied on the two date pickers and the other drop down control. This validation rules will trigger if user changes value in any ...

Special case when calling InvokeScript with the winforms WebBrowser control does not work

I am trying to use InvokeScript method on the WebBrowser control to execute a script on the web page that has been loaded into my WebBrowser control. If I am calling just a simple javascript function, this works properly. However, the javascript function that I am trying to call is nested within a variable like this: var holder = { ...

ContextMenuStrip and mouse wheel

I have a ContextMenuStrip with many items. How to handle ouse wheel to scroll throught items? I search the net but nothing find usefull. Or how to get first/last displayed/visible item from contextmenu? ...

how to sort string as number in datagridview in winforms

I have string column with numbers in a datagridview.It is not bound, I would like to sort it number wise I used colid.ValueType = typeof(int); grid.Sort(colid, ListSortDirection.Descending); but is sorts like string eg: 11 12 23 7 80 81 while the expexted is 7 11 12 23 80 81 ...

Random GUI errors using C# Mono on Mac OS X

I'm developing an application in C# (Windows Forms), which uses Mono to run on Mac OS X. It contains some dynamic controls, for example a custom groupbox which contains some labels and textboxes, a button, etc.These boxes can both be added and removed dynamically. My CustomGrpBx inherits from GroupBox and this is the contructor I use: ...