Skip to content

Windows Forms

Desktop and Windows Forms development

This category can be followed from the open social web via the handle windows-forms@forum.codeproject.com

2.1k Topics 7.1k Posts
  • ComboBox and DataSet binding

    tutorial wpf wcf question discussion
    2
    0 Votes
    2 Posts
    8 Views
    K
    I am not totally sure I understand the question, but you can not set the selected item by setting the selectedValue or selectedText. You can only set the selected Item by using the SelectedIndex and SelectedItem. If you want to select AL then you would need to do something like: You might need to loop through the comboBox to check the value and find the index. cbState.SelectedIndex = columnIdx Hope that helps. Ben
  • Is it possible to modify InitializeComponent() safely?

    winforms design question
    7
    0 Votes
    7 Posts
    18 Views
    S
    That works fine at run time, but does not show up in the designer, even if you do the work before the InitializeComponent call in the constructor. I am thinking I am just going to have to manually define the table schemas in the dataset and have them filled at run time for the clarity I am going for. It is a bit more work and debugging but those are the breaks I guess. Thanks for helping keep me from going too far off on a tangent. It's kind of weird to mention this but even my horoscope that just hit my hotmail is in agreement with you. "Impose a looser, more go-with-the-flow kind of structure on your work habits, and you just might accomplish even more than you hoped. The payoffs may not be immediate, but they'll greatly benefit your future."
  • Autocomplete File Path

    tutorial
    3
    0 Votes
    3 Posts
    8 Views
    K
    Thanks for your reply. However this link cannot be opened. I managed to get another solution at "Auto-File and URL Completion for Text Boxes and Combo Boxes"
  • Duplicate record from Datagrid.

    sharepoint
    2
    0 Votes
    2 Posts
    7 Views
    H
    Hi, To find duplicated records use the above code sample : DataView v = myDataSet.Tables["YourTable"].DefaultView; v.Sort = "YourPrimaryKey ASC"; Dictionary> duplicatedRecords = new Dictionary>(); for (int i = 0; i< v.Count -1; i++) { int j = i +1; object iValue = v[i]["YourPrimaryKey "]; while (v[j]["YourPrimaryKey "] == iValue) { if (! duplicatedRecords.ContainsKey(i)) { duplicatedRecords.Add(i, new List()); } duplicatedRecords[i].Add(j); j++; } i = j; } HTH. Hayder Marzouk
  • How to persist listbox current item

    csharp winforms tutorial question
    2
    0 Votes
    2 Posts
    6 Views
    R
    I assume the list box contains a static list of items that never changes? If so, this would be (one) way to do it: 1. Create a new user setting 'MyListBoxIndex' of type Int. 2. Create a SelectedIndexChanged event handler for the listbox. 3. In the handler, store the current index using: Properties.Settings.Default.MyListBoxIndex = myListBox.SelectedIndex; 4. After the Application.Run() exits, call Properties.Settings.Default.Save() Whenever the form / control loads that has your listbox on it, retrieve the index from the user setting and select the corresponding index using myListBox.SelectedIndex = Properties.Settings.Default.MyListBoxIndex; Hope this helps, Roel
  • 0 Votes
    2 Posts
    6 Views
    D
    Using the standard drivers for USB, you can't do what you want, no matter what language you use. Hardware is shared system-wide and is completely abstracted from your application, giving you no control over access to the USB ports. You would have to write your own USB drivers in order to support this. Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic      2006, 2007
  • 0 Votes
    6 Posts
    15 Views
    D
    Hi. I ended up temporarily doing the following: F2.cmbPub.SelectedValue = strPub F2.cmbPub.Enabled = False F2.cmbPub.DropDownStyle = ComboBoxStyle.Simple This disables the box showing the selected value only. I am coming from a browse screen that has a datagrid with 2 unbound boolean columns, Edit and Delete. The rest of the columns are bound. When I check the Edit box it shows the detail screen with the information for the selected item. I just wanted to be able to allow the user to display the values in the combo box, but not be able to select from it. I wanted the default to be the selected value. I will use the above code for now, but just wanted to know if there was a way to do it. Thanks.
  • How to push submit button from code behind?

    csharp tutorial question
    3
    0 Votes
    3 Posts
    8 Views
    N
    Thank you Ben, I got it to work! :laugh: Sorry about the cross the cross post. Niklas
  • 0 Votes
    2 Posts
    7 Views
    D
    sorry. This is VB .NET.
  • 0 Votes
    1 Posts
    3 Views
    No one has replied
  • 0 Votes
    3 Posts
    8 Views
    A
    hi, thanx for the reply, i cann't use this approach becoz i have to further use InternetExplorer Class Properties, why is n't working.... Dotnet
  • 0 Votes
    1 Posts
    3 Views
    No one has replied
  • vertical scrollbar [modified]

    database tutorial
    2
    0 Votes
    2 Posts
    5 Views
    C
    You need to write a control to do this. You would just use the MEasureString method on the graphics class to work out if your text is going to be oversize, show a scrollbar accordingly, and redraw the string offset by the scrollbar position when a scroll event occurs. Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
  • Windows Forms book suggestions

    csharp winforms question asp-net lounge
    3
    0 Votes
    3 Posts
    8 Views
    R
    Another great (advanced) book is: "Pro .Net 2.0 Windows Forms and Custom Controls in C#" by Matthew MacDonald (long title):zzz: But with over 1000 pages it definitely covers a lot of GOOD material related to windows forms. Cheers! Richard
  • 0 Votes
    4 Posts
    12 Views
    R
    If you are wanting to create the control yourself you better have some nerve pills on hand. :) All of the functionality you mentioned will have to be created from scratch which will require a lot of paint and logic code. You will also need a good reference book. Check out: http//www.apress.com for a custom controls book. Good Luck! Richard
  • Lookup in DataGridView

    question css database wpf wcf
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • Anybody worked on install/uninstall windows service?

    question
    3
    0 Votes
    3 Posts
    8 Views
    S
    There can also be problems if the Services control panel applet is running when the service is removed. It will sometimes "persist" until a reboot occurs. ----------------------------- In just two days, tomorrow will be yesterday.
  • Windows service to watch a directory

    csharp com help
    3
    0 Votes
    3 Posts
    6 Views
    M
    Just so you know, unlike some other forums replying to yourself does not bump your post to the top. Look at this article, it may not be great but it doese mention what you are having a problem with[^] CleaKO "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy) "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
  • 0 Votes
    3 Posts
    8 Views
    C
    1 - fix your caps lock key 2 - buy a book 3 - work through it 4 - ask *specific* questions when you get stuck Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
  • Dockable forms

    csharp visual-studio question
    7
    0 Votes
    7 Posts
    22 Views
    N
    In code project itself its there , including it's source code .Frankly it's complete Develop2Program & Program2Develop