winforms

Irregularities when adding controls to my panel. They show up whever they want!

Here's my code: int ypos = 0; public void X() { MovieItem NewMovie = new MovieItem(); NewMovie.SearchMovie(txtSearch.Text); NewMovie.Location = new Point(0, ypos); ypos += 196; panel1.Controls.Add(NewMovie); } After running method X about 4,5 times, the 5th or 6th item added isn't added where it should instead it...

How to get callbacks for a ListView sub-item? (Partial Owner-draw)

I have a ListView that contains items with four columns. The values in three of the columns are pretty much fixed (although editable via an item editing dialog), but the value in the fourth is an index, and I want it to be calculated on the fly. I know that I could use an owner-draw list, but, unless I don't get the examples in MSDN, it...

How do you ensure windows applications and windows services access the same ProgramData on Win2008 x64?

I have a windows forms application that reads and updates an XML file with information which a windows service must act on. This has been working on Windows Server 2003, XP and Vista (x32) for some time. Now, when installed on Windows Server 2008 x64, strange things have started happening, thanks I assume to the User "VirtualStore" fol...

C# Method Wait For User Click

Hello, I am trying to write a method that loops and repeatedly calls other methods. There is a single place inside the loop that I need to pause and wait for a user to click one of several buttons on the GUI. I have done this with command line code before, but I'm not sure how to wait and check it any buttons have been clicked. If som...

Direct access to TableLayoutPanel Cells

I have a TableLayoutPanel where each cell contains a single panel. I would like to be able to directly access any one of the cells by row and column and do something to the panel in it. I cannot for the life of me figure out if I can access controls within a cell. It would be great if I could do something like: Panel p = layoutPanel.Ce...

Mutltithread: writing to public lists in many instances, need of lock?

Hi, At first I assume I do need writerlock here but Im not sure (not much experience with that) what if I dont use it. On the server side, there are client classes for each connected client. Each class contains public list which every other class can write to. Client requests are processed via threadpool workitems. class client { publ...

Getting DocumentSteam for html websites without using a Winforms WebBrowser control for parsing?

Getting DocumentSteam for html websites without using a Winforms WebBrowser control for parsing? Is this possible? I would like to create some types like: HtmlDocument doc = new HtmlDocument ("http://www.ms.com"); DocumentStream ds = doc.GetFullStream(); ... Also if possible, please post code. ...

System.Windows.Forms.SaveFileDialog does not enforce default extension

I am trying to make SaveFileDialog and FileOpenDialog enforce an extension to the file name entered by the user. I've tried using the sample proposed in question 389070 but it does not work as intended: var dialog = new SaveFileDialog()) dialog.AddExtension = true; dialog.DefaultExt = "foo"; dialog.Filter = "Foo Document (*.foo)|*.foo"...

Systray bubble not showing up (with enabled baloons in XP)

Hi, I was wondering what is wrong and after searching here I found out it could be due to disabled balloons, but thats not my case. I am using simple code, but it doesnt work. Thank you NotifyIcon ntf = new NotifyIcon(); ntf.BalloonTipText="bla"; ntf.Visible=true; ntf.ShowBalloonTip(3000); ...

How to replace FileName in SaveFileDialog.FileOk event handler

I'd like to change the file name of the SaveFileDialog in the event handler attached to the FileOk event, in order to replace the file name typed in by the user with another file name in some cases, while keeping the dialog open: var dialog = new SaveFileDialog(); ... dialog.FileOk += delegate (object sender, CancelEventArgs e) ...

How do I keep a form from going blank while my program working with out using a background worker?

On a regular basis I find myself writing little utility programs that use some loop which takes a while to process. Yet while the loop is going the form no longer refreshes so if you were to move the form, or move another window over it and off, the form would be blank until the loop finishes. Now I know the correct way to deal with thi...

C# Anchor property doesn't seem to work

I added some controls to my form and changed Anchor property how I'd expect this to work, but when I resize the form at the runtime, the controls stay at the same place. For example, I have two buttons in bottom right corner of a form - they are on the form, no containers or anything like that. Anchor = Bottom, Right. FormBorderStyle = ...

How can I call the Control color, I mean the default forms color?

For instance, to make something blue I would go: this.BackColor = Color.LightBlue; How can I summon the Control color, the khaki one. Thanks SO. ...

Weird debug problem: There is no source code available for the current location

I have a WinForms app in a single project written in VB.Net 2003 (legacy code). There is a MainForm and a SecondaryForm that is run by the MainForm. When I run the app thru the MainForm, I can debug with no problem. However, if I just run the SecondaryForm, I get the debug error, "There is no source code available for the current loca...

Making a ToolStripSeparator horizontal in a vertical toolbar in WinForms

Hi, have Googled and cannot find out how to make a ToolStripSeparator "draw" an horizontal line in a toolbar that is aligned vertical. The separator is drawn vertically which makes it awful. Eg. * - item * * | <- separator * * when it should be * * - <- separator * * ...

Winforms for a java swing guy [Applying MVC]

I am developing a GUI application in C# using the design mode in VS2008. Now that I am finished with the looks of the application I am ready to add some functionality to it. What really confuses me though, is that VS2008 designer only uses the empty constructor. When developing applications in Java I normally pass around a model and con...

C#: Binding hashtable to combo box question

public class FontType { ... public String Name { get { return _name; } } public String DisplayName { get { return _displayName; } } public Font UseFont { get { return _font; } } } bindFontTypes.DataSource = availableFonts; comboFontType.DataSource = bindFontTypes; comboFontType.ValueMember = ...

Is there a way to implement a flat TextBox in C#?

I have a GUI with a flat style for the buttons. I would like to use TextBox controls with the same appearance, but I can't find where can I configure the outer line with. Is there any control in WinForms which can be given FlatStyle? Thanks! Edit 1 Thanks for the information about FixedSingle border style, but then, how can I change ...

Programmatic data in .NET Winforms DataGrid

I'm getting a weird behavior with a datagrid. No matter what I do, it's ordering the columns arbitrarily and adding all the columns in the objects. I'm using .NET 3.5, with a winforms datagrid. The Datasource is set at runtime, not design time. I've tried defining the columns in the GDI, but it ignores the order. Even if I only defi...

How to "bypass" constructor call if instance is not null (WinForms designer code)

Hi, When we place a component on a Windows Form, the default behavior for the designer is to serialize a contructor call in the IntializeComponent method of the form. Is there any way to have a custom serializer output the following code: if (componentInstance == null) componentInstance = new componentClass(); instead of just: c...