Using ApplicationSettings To Store Checked Property For WinForms RadioButtons

Jun 1, 2009

I have a WinForms dialog box that contains 3 radio buttons. I am using ApplicationSettings to bind the Checked property of each of these RadioButton controls, but it doesn't do what I am expecting it to do. Now I have to click each radio button twice before it gets checked and the selected radio button is not being persisted.Is there a line of code I need to execute when the form is closed that saves the user settings?How do I eliminate the need for 2x clicking on the radio buttons?Is there a better way to persist this type of user setting? I do have a public property on the dialog box class that gets/sets an enum value based on which radio button is checked, but I didn't see an easy way of binding that property to a user setting. Should have specified that I'm using vb.net. I think that means My.Settings instead of Properties.Settings.

View 4 Replies


ADVERTISEMENT

VS 2010 - ApplicationSettings Property Binding For Checked State Of Menu Items

Nov 19, 2010

I want to use property bindings under application settings to store settings for my program. However I have run into a problem. For some reason the checked property is not binding to drop down menu item's checked state. The binding works for text boxes and other controls. I have tried to bind both using the checked property, and checked state property. Auto check on click for the menu items are set to true.

Anyone have any recommendations in getting the app-settings property binding to work without the need to manually set that info and manually run My.Settings.Save?

View 2 Replies

.net - Make A Class Property Behave Like The Checked Property On RadioButton?

Jun 1, 2012

I have a very simple class that holds a few public properties - ID, Text, Colour, etc. and a Boolean called 'SelectedItem'. Just like the Checked property on RadioButtons, only one item can have its SelectedItem property set to True within a particular group. Note: there will be several separate groups (lists), each allowed to have only one item with SelectedItem = True.

My first thought was that I would probably just have to handle everything outside of the class, setting SelectedItem to False for every other item in a particular list when another item was selected. But that seems rather inelegant to me. So I've been trying to think of how this might be done within the class. For example: could I perhaps have a private string property called say "GroupName" - set in the New sub when adding a new instance of the class - and then use a private shared method to set every item's SelectedItem property to False, provided the item has the same GroupName as the newly selected item? I would have a go at doing this but I have no idea how to enumerate every instance of a class from within that class, or whether that's even possible. Is it? Or is there another (better) way to achieve my goal? Here is a cut-down version of what I've got so far:

Public Class ResourceItem
Public ID As Integer
Public Text As String[code]....

As can be seen: instead of instantiating a new ResourceItem and passing that as an argument to the manager's Add procedure, I'm simply passing the details of the new item and the procedure is creating the item from those. I don't know whether this is a good or bad idea - please advise - but I've done it because I couldn't figure out how to make the SelectedItem property only writeable by the manager, so I wanted to avoid having directly accessible objects that could have their SelectedItem property set to True without it deselecting all the other items in the same group. Of course that still leaves the possibility of setting a variable to one of the manager's list items and setting it from there, so I would still like to know how I could prevent that, if possible.

UPDATE: I didn't use the code above in the end, deciding instead to go with Cyborgx37's solution - which seems to work perfectly well for me despite the warnings about best practice. I also realised I would need to use the same class in another scenario where multiple items could be selected, so it was easy to add a Boolean property to the manager to enable that.

View 2 Replies

VS 2008 - Selecting Radiobuttons Using Radiobuttons And More

Apr 24, 2009

1) My program has 3 groupboxes each consisting 3 radiobuttons. Based on what is checked in the first box, and then what the user chooses in the second box, I either need to hide the 3 box and choose one option, or keep it showing for the user to select an option. The hiding is because based on the previous choices, there is only one option for the user in the 3rd box, and so I don't want to confuse the user nor waste their time. So I when the user selects radiobutton1, I need to hide groupbox3 and select radiobutton2.This is what I have previously attempted and it didn't work.

[code]...

How can I select the radiobutton using code like shown above?2) My second question is regarding scanning strings. I have 2 output strings. They either print a device or a message saying why the user doesn't get an output. At the end of the code, I need to scan through the strings until I get to a space and then store that as a string. How does one go about doing this?

View 7 Replies

Implement A Checked Combobox In WinForms?

Jan 11, 2012

Does anyone know of a simple implementation of a checked combobox in WinForms? I haven't been able to find anything when googling.

I want something that behaves like this windows scheduled task trigger edit:

View 3 Replies

Winforms - Iterate Over The Items And Find Out Which Checkboxes Are Checked?

Feb 26, 2009

I am using the winform datarepeater control from vb.net power pack. All of the items on the repeater are readonly except for a checkbox column.I want to iterate over the items and find out which checkboxes are checked. I can't find a collection of datarepeateritems on the control and help is scarce.

View 3 Replies

WinForms - Where To Store Connection String

Feb 17, 2010

I am working asp.net for a few years. In asp.net, database connection string is stored at web.config file. All page can share this connection string. Now, I need to learn how to create windows app. Where to store a connection string, e.g. connect to SQL, to Access DB, so that all windows forms can share it?

View 5 Replies

Checked List Box With Data Value Property For Each Item?

Apr 12, 2011

Does anyone know of a control such as a Checked List Box where each item can have a value against it.For example you have a list of fruits and in the listbox it displays Apple, Orange & Banana but the values for those items are A, O & B.

View 3 Replies

How To Insert Checked Property In User Control

Oct 12, 2009

I am trying to make a control, like a toggle control like a on/off button and I need to insert/create a property, a checked property.

View 1 Replies

CheckBox DataBindings - Checked Versus CheckState Property

Jan 18, 2010

What are the pros and cons of using the checkboxes checked property vs the CheckState property for databinding?

View 1 Replies

Get Sub To Address Appropriate Control / Can Set Its 'checked' Property Based On Text Read

Jan 2, 2012

I have a form with about 48 checkboxes.I have a public sub that reads a webpage, parse the text of that site to get the values that correspond to these checkboxes.For example: one of the lines would be: "Exterior = 255", or "Street = 0".I do have check boxes that called "Exterior" and "Street". the question is how I can get my sub to address the appropriate control so I can set its "checked" property based on the text read.

View 3 Replies

Reading 'Checked' Property Of Dynamic CheckBox On Page Postback

Dec 29, 2009

How can I check the 'Checked' property of a dynamically-created checkbox during the Page_Load subroutine? Basically, I have a VB.NET page that creates some table rows dynamically, based on a number selected by the user. So, for example, if the user selects "3" from a dropdown list, the page posts back and creates three table rows. Each row contains a couple of textboxes, a dropdown list, and a checkbox (which are all .NET form controls rather than plain HTML controls, I should point out).Typically, the user would enter a few details into the form controls, and click the 'Submit' button, after which the page iterates through each row, and inserts the data into a SQL Server table.But if the user ticks the checkbox for that row, this signifies that the page is to ignore that row, and NOT insert that row of data into the database when the user clicks 'Submit'. This works well, but there is a problem. If the user clicks 'Submit' and some of the values entered into the form controls are invalid (so, for example, the user didn't enter their name) then the page won't submit the data, and instead, shows an error to the user informing them of the values they need to change. But if the user creates three rows, for example, but decides to "ignore" the third row (by ticking the checkbox) then when the page posts back, finds some invalid entries, and re-shows the form to the user to allow them to correct any errors, I'd rather the page didn't render the third row altogether. After all, they chose to create three rows originally, but then decided that they only needed two. So it makes sense that the third row is not recreated.

But what seemed to happen was that objCheckbox.Checked was always returning False, even when the checkbox was ticked. Once the page had loaded, the table rows had rendered again, and the tick was present in the checkbox, so it's not like the value was lost on postback. But at the point I check whether the checkbox is ticked, it always returns False, rendering a table row that the user doesn't need.Does anyone know how to get round this problem? I've read lots of articles about the .NET ViewState, and the page lifecycle, but I've yet to find a solution that works. I simply need to be able to check if a checkbox is ticked before re-creating some dynamic controls. [code] But then I basically found out that you can't override a protected member with a public one.

View 1 Replies

VS 2008 Override The Method ToString() For The Property CheckBox.Checked?

Mar 13, 2011

How would I override the method ToString() for the property CheckBox.Checked?

View 2 Replies

C# - Binding Property To Control In Winforms?

May 4, 2011

What is the best way to bind a property to a control so that when the property value is changed, the control's bound property changes with it.So if I have a property "FirstName" which I want to bind to a textbox "txtFirstName" text value. If I change FirstName to "Stack" the txtFirstName.Text also changes to "Stack".

View 1 Replies

Sql - Equivalent For Value-property For Controls In Winforms?

May 3, 2012

I'm used to webdeveloping, and when I work with databases, I usually use some text for the Text-property of a radio button, and the row's ID as Value-property. This makes it very easy to save to databases.

Is the an equivalent in winforms for the Value-property, or will I have to identify rows based on the text in the control?

View 2 Replies

Overriding Default Property Values In .Net, WinForms?

Jan 9, 2010

I create a class "Planet" that can be inherited. One of the purposes of inheriting is to create a template with different default property values. Eg:

Public Sub New
MyBase.New
MyBase.ForeColor = Red

[code]....

Now, to stop the defaults serializing in the InitializeComponent method, there are 2 ways:If I've implemented the properties using the 'DefaultValue' attribute, and made them overridable, the attribute can be overriden with the new value.The problem with this is, there's no way to just make just the attributes overridable, as opposed to the whole property.I could implement every property with protected Reset'PropertyName' and ShouldSerialize'PropertyName' methods. However, this is a bit of a pain in the arse.Is it, generally, an important consideration to ensure that someone who overrides your base class has the ability to change the default values of a property?

View 1 Replies

.net - Winforms, BindingList, BindingSource - Cannot Bind To Property/column Id

Feb 28, 2011

I have the following code on a form:

Public Sub Init(ByVal SelectedItems As List(Of Cheque))
Items = New BindingList(Of Cheque)(SelectedItems )
BindingSource1.DataSource = Items

[code]....

This code gets called like so:

...
fmEdit.Init(myList)
fmEdit.Show()

All variables are populated etc, it seems to go through the DataBindings.Add ok but when the form appears I get the error about unable to bind to a property or column called Id. I tried replacing the DataBindings.Add code to use the BindingSource1 instead of Items but I get a similar error.The names of the properties in the class match that of the name in the Databindings.Add code.

UPDATE: Here is my class:

Public Class Cheque
Public Id As String
Public Status As Byte

[code]....

View 1 Replies

Changing Dock Property In Winforms User Control

May 5, 2011

I'm trying to create a button that will hide the panel that I have docked at the centre of my user control. [code]This works to an extent. However, when the bottomPanel is set to Fill it seems to fill the entire control, and not just up to toolStrip1. Can anyone tell me why this is happening, and how to correct it?

View 1 Replies

WinForms - Editing Custom Readonly Collection In Property Grid

Feb 19, 2010

I have a custom collection, lets says COL, that derives from ObjectModel.Collection. I have my own collection editor that works fine when a property, of type COL, is Read and Write enabled. However, if I change the property to ReadOnly, the open editor button stops showing in the property grid. As a test, I override my custom editor with the CollectionEditor, and that worked fine. So, my question is, what check is the property grid making, that CollectionEditor passes but my collection editor fails?

View 2 Replies

Store And Then Raise Event In Property Of Attribute

Apr 9, 2009

I think know how to do this in C# but I'm having syntax trouble in VB.NET because I need to take advantage of the 'handles' event stuff. I have different events that I somehow (probably delegate) need stored in a property of an attribute (I just add an attribute to a property linking to the corresponding event).

E.g.
<BindEvent(EventThing)>_
Public ReadOnly Property IsTrue() As Boolean
Get
Return True
End Get
End Property

They need to be events so that other programmers can use the VB.NET handles keyword on methods.
Public Delegate Sub TestEvent(ByVal sender As Object, ByVal e As Object)
Public Event E As TestEvent
Public Sub Test() Handles E
End Sub

These properties are already raising a general event, which I am catching, determining the related property and thus getting the related attribute (and delegate/event). I want to then raise the event that's related. If I just use a delegate tied to the particular event that won't raise other handlers will it? I also want to avoid having to write a sub for each property that just uses Raise Event on the event type if possible as this seems redundant.

E.g. avoid:
Public Event E As TestEvent
Public Sub CallE(ByVal sender As Object, ByVal e As Object)
RaiseEvent E(sender, e)
End Sub
[Code] .....

View 2 Replies

VS 2005 Store / Retrieve Variable Or Property?

Oct 27, 2009

In the application I'm documenting, sometimes a value is stored in a Public variable & other times it's passed to/from a Public Property which does nothing except store it in/retrieve it from a Private variable. (And in one memorable exception, the Public Property stored it in a Public variable-I'm almost certain that was an oversight by the original programmer though.)

I know that passing it to/from the Public Property has the potential for better validation, but if the Property doesn't actually do anything except store/retrieve it is there any benefit to declaring it as a Property? (Or maybe I should put that the other way around. Personally I'd declare them all as properties because that will allow adding validation later-but I'm not rewriting this, I'm just trying to document it and, in this case, trying to figure out why sometimes it's done as a property & sometimes as a Public variable.)

View 2 Replies

Refresh ApplicationSettings In A Dll?

Jan 20, 2010

Can i force a dll to reload it's configuration?[code]...

but it look like that the value "This is an entry" is embedded into the dll's code. If I change it in the app.config or in the ComWrapper.dll.config file it has no effect on the return value.

View 3 Replies

C# - Refresh Property Grid, At Design-time, When A Readonly Collection Changes In .Net, Winforms?

Mar 3, 2010

I have a class that has a readonly collection property - Its a list of extender providers that have been applied to the control.I've implemented a simple property descriptor for the collection so that the property can be expanded in the property grid to examine each entry.

When I select an extender provider and set it to false, I remove it from the collection. The GetProperties method of the type converter is requeried and the property grid refreshes.However, when I set an extender provider to true, and thus add it to the collection, GetProperties is not requeried.

Somehow, the property grid is making a distinction between adding to and removing from the collection. Or alternativly, its refreshing when an extender provider is added, but not when one is removed.

[Code]...

View 1 Replies

Persisting A Collection, That References An Internal Property, At Design Time In Winforms, .net?

Mar 11, 2010

(I've answered the question below with a hack. I'm fairly confident in it unless MS change the way that codedom serializers the designer code.)ETA2:I've worked out what is going on. I wondered why sometimes it would work and not others. It boils down to the name that I give to the internal property and the collection.If I rename the property 'Annoyance' to 'WTF', it will serialize correctly because 'WTF' is, alphabetically, after the name of the collection - 'InternalAnger'.It looks like the serializer is creating instances of objects alphabetically and needs my internal property to be created by the time it comes to create the collection.I can fix this with a rename, but that's a hack and I fear that writing a custom serializer is a big job - which I've never done before.ETA: Jesus, I'm sick of this. This problem was specifically about persisting an interface collection but now on further testing it doesn't work for a normal collection. Here's some even simpler code:

Public Class Anger
End Class
Public Class MyButton

[code].....

View 4 Replies

Simple Databinding - Handle Bound Field/property Change - Winforms / .Net?

Oct 19, 2009

I have a custom control with a bindable property:-

Private _Value As Object
<Bindable(True), ... > _
Public Property Value() As Object
Get

[code]....

Also, here, I'm adding a handler to the DataBindings.CollectionChanged event.This is the second place that I retrieve the type:-

Private Sub DataBindings_CollectionChanged(ByVal sender As Object, ByVal e As System.ComponentModel.CollectionChangeEventArgs)
If e.Action = CollectionChangeAction.Add Then
Dim b As Binding = DirectCast(e.Element, Binding)

[code]....

I need the first place, because the BindingContextChanged event is not fired until some time after InitializeComponent.The second place is needed if the binding field is programatically changed.Am I handling the correct events here, or is there a cleaner way to do it?

Note: My GetValueType method uses the CurrencyManager.GetItemProperties....etc, to retrieve the type.

View 1 Replies

AppSettings And ApplicationSettings ConfigurationManager

Jan 15, 2008

why are application settings stored in "applicationSettings" when the ConfigurationManager is looking in the old appSettings area in a config file?

View 6 Replies

C# - RefreshProperties Attribute At Class Level In .net, Winforms + Incorrectly Refreshing Property Grid?

Feb 15, 2010

I had a strange problem editing a class in the property grid whereby the property grid would refresh incorrectly.I managed to reduce the problem down to a class with just two properties. I've included the code at the end to ease explanation.It basically boils down to a class with two properties. The first of which is expandable (a font)The class itself is expandable and also implements the CreateInstance method in the type converter.To see the problem, expand the font, edit, say 'Bold', and tab away. Two problems happen:

(1) The second property jumps up and ends up in the expanded font property.

(2) The '-' sign of the expanded font changes to a '+'.

The problem goes away by attaching ResfreshProperties(RefreshProperties.All) to the class. That's great, but I'd like to understand how it fixed the problem. I've had a look in reflector and can't find any examples of RefreshProperties being attached at the class level.

[code]...

View 1 Replies

Winforms - Store The Persons Username In Some Form Of Global "cookie"?

Jan 29, 2012

Ive done a login in vb.net (Visual Studio) which works like a charm. However, i need to store the username of the person that has logged in, in some form of cookie. How can i store the persons username in some form of global "cookie"? It will be cleared when they log out or the program closes PS. I dont literally mean a web cookie - just not sure what else to call it. Just a global variable which will store the current user.

[Code]...

View 1 Replies

Accessing Configuration/applicationsettings During Installerclass?

Nov 22, 2008

I am trying to update the CallDirectory in our app.config file during installation. The file exists, however I cannot seem to narrow down the right key combination using the Configuration classes. I am thinking <CallCtrl.Settings> throw it off as this is differant from previous versions. This is the default structure created by Setting.Setting w/in the VSDesigner.

[Code]...

View 3 Replies

Change App.config Applicationsettings During Install?

Jan 25, 2010

I have application scoped settings set within my application's project properties that are working fine, but I would prefer not to have these settings hardcoded within the progarm.My goal is to modify these settings during application install, by reading from a file located with the setup MSI file.I have an insaller class successfully running and reading values from a file that I wish to change the application settings to. Unfortunatley, I am unable to figure out how to access these application scoped settings.

* I attempted writing directly to the app.conf file, but only ended up with an appsettings section as opposed to updating the specific application settings I was after

Dim targetDir As String = Context.Parameters("targetdir")
Dim templatedir As String = Context.Parameters("templatedir")
Dim savedir As String = Context.Parameters("savedir")
Dim exePath As String = String.Format("{0}myAppName.exe", targetDir)

[code]....

From within my Installer class, how best do a directly change these 2 applicationsettings?After searching / reading many posts and MSDN Class definitons, I am not able to figure it out.

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved