Search Results

Search found 2806 results on 113 pages for 'winforms'.

Page 54/113 | < Previous Page | 50 51 52 53 54 55 56 57 58 59 60 61  | Next Page >

  • How to give a textbox a fixed width of 17,5 cm?

    - by Natrium
    I have an application with a textbox, and the width of the textbox on the screen must always be 17,5 centimeters on the screen of the user. This is what I tried so far: const double centimeter = 17.5; // the width I need const double inches = centimeter * 0.393700787; // convert centimeter to inches float dpi = GetDpiX(); // get the dpi. 96 in my case. var pixels = dpi*inches; // this should give me the amount of pixels textbox1.Width = Convert.ToInt32(pixels); // set it. Done. private float GetDpiX() { floar returnValue; Graphics graphics = CreateGraphics(); returnValue = graphics.DpiX; graphics.Dispose(); // don’t forget to release the unnecessary resources return returnValue; } But this gives me different sizes with different resolutions. It gives me 13 cm with 1680 x 1050 and 19,5 cm with 1024 x 768. What am I doing wrong?

    Read the article

  • Updating ToolStripProgressBar and ToolStripStatusLabel along with with an action

    - by TChristian
    In a Windows Form, I have a search box that fires an event to search a remote database and display some results. The query is pretty fast, usually just a fraction of a second, but in case the delay is noticeable there is a progress bar and label in the form's status bar. When the user clicks "Search" the status label should appear and the progress bar show some progress. Then when the result comes back the label should disappear and the progress bar should be full. Pretty basic response. The problem is, I can't get those actions to happen in that order. Using the code below, I click "Search", nothing happens until the results are displayed, and then the progress bar fills up from 0 to 100. The label never appears. I even threw in a sleep command immediately after the event to be sure I wasn't just missing it, but it's as if the first 2 statements are not being executed. What am I doing wrong here? private void searchButton_Click(object sender, EventArgs e) { toolStripStatusLabel1.Visible = true; toolStripProgressBar1.Value = 20; m_changeRequestedEvents.Fire<String>("SearchTerm", searchTextBox.Text); toolStripProgressBar1.Value = 100; toolStripStatusLabel1.Visible = false; }

    Read the article

  • How to make a ToolStripComboBox to fill all the space available on a ToolStrip?

    - by Ivan
    A ToolStripComboBox is placed after a ToolStripButton and is folowed by another one, which is right-aligned. How do I best set up the ToolStripComboBox to always adjust its length to fill all the space available between the preceeding and the folowing ToolStripButtons? In past I used to handle a parent resize event, calculate the new length to set based on neighboring elements coordinates and setting the new size. But now, as I am developing a new application, I wonder if there is no better way.

    Read the article

  • WPF or Windows Forms

    - by Luminose
    I've been playing around with C# console applications for about a year and I want to move on to creating GUI applications. I have never done any GUI development besides basic Java applications, but I want to continue using C#. Should I start learning Windows Forms or jump straight to WPF? Is there a huge difference? Does WPF build on top of Windows Forms or are they totally different?

    Read the article

  • DataGridView Cell Validating only when 'Enter' is pressed

    - by Eldad
    Hi, I want to validate and commit the value entered in the DataGridViewCell ONLY when the user presses the 'Enter' key. If the users presses any other key or mouse button (Arrow keys, Pressing a different cell using the mouse...), I want the behavior to be similar to the 'ESC' key: Move the focus to the new cell and revert the edited cell value to its previous value.

    Read the article

  • How to ensure DB security for a Windows Forms application?

    - by Vilx-
    The basic setup is classic - you're creating a Windows Forms application that connects to a DB and does all kinds of enterprise-y stuff. Naturally, such an application will have many users with different access rights in the DB, and each with their own login name and password. So how do you implement this? One way is to create a DB login for every application user, but that's a pretty serious thing to do, which even requires admin rights on the DB server, etc. If the DB server hosts several applications, the admins are quite likely not to be happy with this. In the web world typically one creates his own "Users" table which contains all the necessary info, and uses one fixed DB login for all interaction. That is all nice for a web app, but a windows forms can't hide this master login information, negating security altogether. (It can try to hide, but all such attempts are easily broken with a bit of effort). So... is there some middle way? Perhaps logging in with a fixed login, and then elevating priviledges from a special stored procedure which checks the username and password?

    Read the article

  • DataGridView's SelectionChange event firing more than once on DataBinding

    - by Shantanu Gupta
    This Code triggers selection change event twice. how can I prevent it ? Currently i m using a flag or focused property to prevent this. But what is the actual way ? I am using it on winfoms EDIT Mistake in writing Question, here is the correct code that i wanted to ask private void frmGuestInfo_Load(object sender, EventArgs e) { this.dgvGuestInfo.SelectionChanged -= new System.EventHandler(this.dgvGuestInfo_SelectionChanged); dgvGuestInfo.DataSource=dsFillControls.Tables["tblName"]; this.dgvGuestInfo.SelectionChanged += new System.EventHandler(this.dgvGuestInfo_SelectionChanged); } private void dgvGuestInfo_SelectionChanged(object sender, EventArgs e) { }

    Read the article

  • putting numbers in an array into arraylist

    - by arash
    i have numbers that user enter in textBox3 and i converted them to an array nums now i want to put half of them in arraylist A and half of them in arraylist B how can i do that?thanks string[] source = textBox3.Text.Split(','); int[] nums = new int[source.Length]; for (int i = 0; i < source.Length; i++) { nums[i] = Convert.ToInt32(source[i]); } ArrayList A = new ArrayList(); ArrayList B = new ArrayList();

    Read the article

  • How to: generate UnhandledException?

    - by serhio
    I use this code to catch the WinForm application UnhandledException. [STAThread] static void Main(string[] args) { // Add the event handler for handling UI thread exceptions to the event. Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); // Set the unhandled exception mode to force all Windows Forms errors // to go through our handler. Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // Add the event handler for handling non-UI thread exceptions to the event. AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); try { Application.Run(new MainForm()); } catch.... There I will try to restart the application. Now my problem is to simulate a exception like this. I tried before try (in main): throw new NullReferenceException("test"); VS caught it. Tried also in MainForm code with button : private void button1_Click(object sender, EventArgs ev) { ThreadPool.QueueUserWorkItem(new WaitCallback(TestMe), null); } protected void TestMe(object state) { string s = state.ToString(); } did not help, VS caught it, even in Release mode. How should I, finally, force the application generate UnhandleldException? Will I be able to restart the application in CurrentDomain_UnhandledException?

    Read the article

  • Folder Browser Dialog.

    - by Harikrishna
    I am using Folder Browser Dialog in my application to select a folder. Now I want such a thing that in the folder there should be only html files nothing else to be selected. Like if we have open file dialog and only we want to display html file then we use filter property of openfiledialog.So how can I do that in folder browser dialog to remain or select only html files in the folder ? That is how can I filter files in the folder browser dialog ?

    Read the article

  • How can i Update /Get values in windows form while moving one form to other form(like cookies)?

    - by Jeyavel
    Hi, How can i Update /Get values in windows form while moving one form to other form(like cookies)? i need to update the values to some variable and again i am going to refer stored values and need to do some calculations. i have used Cookies in ASP.Net but i am not able to find out same concept in C#.net Windows forms . can any one help me for resolve this issues? Regards, Jeyavel N

    Read the article

  • ThreadPool.QueueUserWorkItem new Form CreateHandle Deadlock

    - by bogdanbrudiu
    I have a thread that needs to create a popup Window. I start the thread using ThreadPool.QueueUserWorkItem(new WaitCallback(CreatePopupinThread)) Thew thread creats a new form. The application freases in the new Form constructor at CreateHandle. The Worker Thread is locked... How can I fix this? this is how I create the form var form = new ConfirmationForm { Text = entry.Caption, Label = entry.Text, }; In the constructor the thread enters a deadlock public ConfirmationForm() { InitializeComponent(); }

    Read the article

  • Need to convert string/char to ascii values.

    - by SA
    Hi, I need to convert char to hex values. Refer to the Ascii table but I have a few examples listed below: char 1 = 31 2 = 32 3 = 33 4 = 34 5 = 35 A = 41 a = 61 etc Therefore string str = "12345"; Need to get the converted str = "3132333435"

    Read the article

  • StringConverter with StandardValuesSupported and Autocompletion

    - by Marqus
    I want to develop a StringConverter with standard values, which after attaching it to a PropertyGrid will act like comboBox with autocompletion. The example below will give me a comboBox, but without the autocompletion - user have to expand it and choose manually one of the items. Is there a way to allow user to type the beginning of one of the options, so the combobox will automatically select the matching one? public class ConverterSample : System.ComponentModel.StringConverter { public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { //true means show a combobox return true; } public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return false; } public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(new List<string>(){"Stack", "overflow", "rules"); } List returned by GetStandardValues has to be dynamic, so I can't use any enum there. I took above example from: http://www.codeproject.com/KB/cpp/dropdownproperties.aspx

    Read the article

  • Simple Windows.Forms binding is failing using framework 4.0.

    - by jyoung
    This works under the .net framework 3.5 client. This fails under the .net framework 4.0 client. Was I doing something that was illegal under 3.5 but just happened to work, or is this a bug? Note that in my project 'PropInt' does not raise change events so using ctx[obj1.PropObj2, "PropInt"] is not an option. public class Obj1 { public Obj2 PropObj2 { get; set; } public Obj1() { PropObj2 = new Obj2(); } } public class Obj2 { public int PropInt { get; set; } } static class Program { [STAThread] static void Main() { var ctx = new BindingContext(); var obj1 = new Obj1(); var x1 = ctx[obj1, "PropObj2.PropInt"]; } }

    Read the article

  • Create a overlay screen while a game/program is running?

    - by Dodi300
    Hello. Does anyone know how I can create a screen overflow while a program is running? Mainly while a game is running. If anyone has used xFire or Steam, these use this feature. I've created a winform which starts the game/program and then minimizes. Could the overflow be created in the same winform? Thanks for the help! :)

    Read the article

  • When to draw/layout child controls in UserControl

    - by Ted Elliott
    I have a list-type UserControl (like a ListBox). The items inside the control are another complex UserControl containing a few other controls (ComboBox, TextBox, etc). I'm wondering what the preferred or best method would be to override to draw/layout the child controls. I basically want to trigger this method any time the list changes. I originally had a RedrawItems method that I just called whenever I needed to redraw which added or removed Controls from the Controls collection. But it was getting triggered too early in the lifecycle of the code from some of the designer code. Now I've switched to overriding OnLayout and doing my stuff there. I call PerformLayout when I want to trigger a redraw, such as when the DataSource property changes or when it fires a changed event. Is OnLayout the best place for this? Here is the code: [ComplexBindingProperties("DataSource")] public partial class CustomList : UserControl { private object _dataSource; private CustomListItem _newRow; public CustomList() { InitializeComponent(); } protected override void OnCreateControl() { base.OnCreateControl(); _newRow = new CustomListItem(); Controls.Add(_newRow); } public object DataSource { get { return _dataSource; } set { bool register = _dataSource != value; if (_dataSource != null && _dataSource != value) { UnregisterDataSource(_dataSource); } _dataSource = value; if (_dataSource != null) RegisterDataSource(_dataSource); PerformLayout(); } } public CustomListItem ItemTemplate { get { return _newRow; } } protected override void OnLayout(LayoutEventArgs e) { base.OnLayout(e); int ctrlCount = this.Controls.AsEnumerable().OfType<CustomListItem>().Count(); ctrlCount--; // subtract 1 for the add row var ds = this.DataSource as System.Collections.IList; int itemCount = ds == null? 0 : ds.Count; int maxCount = Math.Max(ctrlCount,itemCount); if (maxCount == 0) return; this.SuspendLayout(); // temporarily remove the template Controls.RemoveAt(Controls.Count-1); for (int i = 0; i < maxCount; i++) { CustomListItem item; if (i >= itemCount) { Controls.RemoveAt(i); } else { if (i >= ctrlCount) { item = ItemTemplate.Copy(); this.Controls.Add(item); item.Location = new Point(0, item.Height * i); item.TabIndex = i + 1; item.ViewMode = true; } else { item = (CustomListItem) Controls[i]; } item.Data = ds[i]; } } this.Controls.Add(ItemTemplate); ItemTemplate.Location = new Point(0, ItemTemplate.Height * maxCount); ItemTemplate.TabIndex = maxCount + 1; this.ResumeLayout(true); } private void RegisterDataSource(object dataSource) { IBindingList ds = dataSource as IBindingList; if (ds != null) { ds.ListChanged += new ListChangedEventHandler(DataSource_ListChanged); } } void DataSource_ListChanged(object sender, ListChangedEventArgs e) { switch (e.ListChangedType) { case ListChangedType.ItemAdded: PerformLayout(); break; case ListChangedType.ItemChanged: break; case ListChangedType.ItemDeleted: PerformLayout(); break; case ListChangedType.ItemMoved: PerformLayout(); break; case ListChangedType.Reset: PerformLayout(); break; default: break; } } private void UnregisterDataSource(object dataSource) { IBindingList ds = dataSource as IBindingList; if (ds != null) { ds.ListChanged -= new ListChangedEventHandler(DataSource_ListChanged); } } }

    Read the article

  • Delete a Row from a DataGridView given its index

    - by Ruben Trancoso
    My DataGridView is a single line selection and theres a rowEnter Event where I get the line index every time the selected line changes. private void rowEnter(object sender, DataGridViewCellEventArgs e) { currentRowIndex = e.RowIndex; } when I press a delete button I use the same index to delete the row myDataSet.Avaliado.Rows[currentRowIndex].Delete(); avaliadoTableAdapter.Update(myDataSet.Avaliado); it works fine if no column in the DataGridView is sorted, otherwise a get an error. What should be the way to know the row index in the dataset that corresponds to the rowindex from the DataGridView?

    Read the article

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

    - by Shantanu Gupta
    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(ref TextBox txtControl, Boolean SetErrorProvider,string msgToShowOnError) { ErrorProvider EP = new ErrorProvider(); if (txtControl.Text == string.Empty) { if(SetErrorProvider==true) EP.SetError(txtControl, msgToShowOnError); return true; } else { if(SetErrorProvider==true) EP.Clear(); return false; } } Issue: Every time the function is called new errorprovider object gets created which i dont want. Every control should not have more than 1 error provider and i should be able to search it just like as done in asp.net to search for some control on a Page. How can I do this

    Read the article

  • How to handle sharepoint web services exceptions

    - by Royson
    Hi, I have developed an application of share point. I am using web services for that. the problem is that while working with my app sometimes i get some exceptions. like, Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown. Stack Strace :: at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at ......... my methods From this exception i cannot understand the main problem. While developing i can debug the code, but now my application is getting launched..i can get error log file from my client which contains this type of excetions. But how to catch exact error.??? Thanks.

    Read the article

< Previous Page | 50 51 52 53 54 55 56 57 58 59 60 61  | Next Page >