winforms

c# listBox DisplayMember

c# WinForms.Listbox. listBox1.DataSource = ds.Tables[0].DefaultView; listBox1.DisplayMember = "Question"; listBox1.ValueMember = "idQuestion"; //for ValueMember showing... textBox2.Text = listBox1.SelectedValue.ToString(); //What I must use for DisplayMember showing? textbox3.Text = ?????????? ...

WinForms ComboBox - How to Check Values

Hello...I am building a WinForms Application in C# .NET The WinForms Application has a ComboBox where the DropDownStyle is set to DropDownList. When the App is launched, I read an XML file to populate the values of the ComboBox. And, at this time, nothing is selected in the ComboBox by default. As a result, buttons Change and Delete are...

C# WinForms disable DPI scaling

I have a WinForm application which hosts many images. When I put the application on a Win7 machines that has a DPI of 120, it completely ruins the look of the form. Is there a way to disable the scaling for my form? I am aware that this is something that is not advised and that DPI should be seamless and handled by the OS. But when it c...

running WCF in windows forms

hello. I've a program working as client and server. I'm using wcf services with BasicHttpBinding and the program is running in a console application. When i moved the code to a windows forms application, everything stops working. When the client side invoke one operation, it doesn't returns. When some operation on server side is invo...

Do you use Hungarian notation for control names?

I totally agree that we should not use Hungarian Notation to name variables. But it seems that Hungarian Notation is still useful to name controls (especially Winform controls). Consider these: GridView grvUsers TextBox txtPassword etc... I really doubt that should we avoid Hungarian notation in this case? If should, which is alterna...

Group by in Datagrid View

Hi, i have a scenario where i have to group the PinCode by city name like one city can have many pincode. I have to do this in winform in datagrid. How can i do this so in datagrid i can see the + and - on before city. I thing it can be done by nested grid. please, help. Column A | Column B | Column C Country Zip Co...

How to create Windows Mobile 6.5.x finger friendly stock controls?

I'm developing a Windows Mobile application in C# using .NET Compact Framework 3.5. My target version of WM is 6.5.x. It was my impression that Microsoft has updated the stock controls in this release of the OS to be more finger friendly (larger fonts, greater space between rows in listboxes, etc.) but when I create, for example, a ListB...

How can i convert the string value to date time value and assign it to DateTimePicker

I stored a date value and retrieve it and the format of the date in the string is yyMMdd. Now when the user loads that from the string i would like to select the DateTimePicker as the user loaded date. Sample code: string strDate = strRead.Substring(23, 6); DateTime dt = DateTime.Parse(strDate); Can any one give me an idea for the ne...

winforms draw border and move when FormBorderStyle set to None

Hi, I display a winform as a dialog (with ShowDialog over a main window). So, I set the FormBorderStyle to None because I wanted neither the control boxes nor the title bar. Though, I would like a border drawn (for example a blue border like normal windows) and keep the ability to move the form. I don't need the ability to resize it. I t...

visual studio grid snap to edge spacing

I'm designing a form in VS2008 and I want to snap controls to the left and right edges of the form but with more space than it gets now. I tried changing the gridsize but that doesn't do it. The form is for the compact framework so i'm designing for a smartphone I don't know if that makes a difference. I guess it ought to be the same...

Trying to sort a ListView with unchecked items at the top and then by ID: compare routine throws an odd exception.

Hi all, I'm building a desktop to-do list app, and in my UI I have a ListView control which lists all the items in each list. Each item/row has a checkbox which updates the status of that item in the database when it is checked or unchecked. So far so good! What I am attempting to do is re-sort the list whenever a checkbox is clicked, ...

Making Vista style apps in C# for windows XP

Hello All, I'm using windows xp and currently im developing an small win form application so I want to give vista or windows 7 appearance to my application which is running in Windows xp and I'm using c# to develop win form application. Is it possible to do that ? If so then please let me know the way. Thanks in Advance Nitesh Katare ...

Error on invoke when the form has closed already

I am trying to display some information on a grid queried from a sql server. The data gathering can take about 10 seconds so I don't want to lock the UI thread. I currently have code like: ThreadPool.QueueUserWorkItem(DataUpdateThread, new UpdateParams(year)); private struct UpdateParams { internal string year; internal Upd...

How to compile Unsafe code in C#

Hi guys I've imported an API function like [DllImport("gdi32.dll")] private unsafe static extern bool SetDeviceGammaRamp(Int32 hdc, void* ramp); while compiling its showing an error like Unsafe code may only appear if compiling with /unsafe how to compile with /unsafe . i'm using Microsoft Visual Studio 2008 can any one help me w...

Form.FormBorderStyle Native Exception Access violation

On a WindowsCE platform (custom build) our C# gui uses regular forms to show an "popup menu". We set the FormBorderstyle to None as we don't want the form controls to be visible. Some clients reported "Gray boxes" after a while. After some testing here we could reproduce the problem quite fast. When we open 2 different menu's (forms) co...

how to display checkbox inside richtextbox for acceptance of Terms and Conditions

I am working on window application. I have a form where I will be displaying terms and conditions against shopping done. Below Terms and Conditions, I want to show Checkbox which user have to check as an acceptance before proceeding. This Checkbox should come below the terms and conditions. If terms and conditions are long enough then ...

InvokeRequired of Form == false and InvokeRequired of contained control == true

Hi, how is it possible? I have windows Form control, derived from System.Windows.Forms.Form with WebBrowser control contained in this form. Webbrowser object instance is created in constructor of form (in InitializeComponent() method). Then in background thread I manipulate with content of WebBrowser, and I found that in some cases Form...

validations in MVC / MVP

I'm new to MVC / MVP and learning it by creating a Winform application. I have to some extent created the Models, Presenters and Views... Now where do my validations fit. I think the initial datatype validation (like only numbers in Age field), should be done by view. Whereas the other validations (like whether age is within 200) shoul...

Pick a date from the datetimepicker

I have a car rental application I am writing. I am having some issue. Basically I want a user to pick a date from dateTimePicker2 then dateTimePicker1 I then want to subtract those numbers from eachother and store it in car. I have created a button that will multiple the per day charge then display it in a label but I just having an issu...

Trouble with Datagridview.ClearSelection()

Hello stackoverflow. I want my (readonly,fullrowselect) datagridviews to have no selected rows when the form is loaded. I tried .ClearSelection in the forms constructor after setting their datasource but it doesn't work (i would really like to know why...). Then i tried in the Form_load event but it won't clear the selection on the dat...