Limit Available Property Values?
Jun 14, 2010
I've got a property MyEnumProp which is displayed in a property grid. The property is of type MyEnum. So all entries of MyEnum are available in the propertygrid to select.Now i have a second property and based on its value i want to limit the values available in the propertyGrid for MyEnumProp.Is there a way to accomplish this?For instance: The following 2 Enums are defined in an Interface:
Enum Country
England
France
[code].....
View 5 Replies
ADVERTISEMENT
Jan 9, 2010
I am making an UserControl which has several properties. One of them should have a specific range of the value - it should only be possible to set the value of the property with a number from 1 to 255. 0 should not be possible, because some calculations are done in which is divided by this property's value. I thought I could use a Byte as type, but a Byte can contain 0 as well. I would like to be able to set a limit for the value of this property, and that an error is shown in the Designer when, in this case, 0 is entered. I mean an error window like you get when filling in 0 for the interval of a Timer. Is this possible with an UserControl as well?
View 2 Replies
Sep 11, 2011
Is there a way to limit the topmost property? I have two forms and I only want to one form form topmost to only one form. I don't want it to be topmost to all of the windows in my computer.
View 4 Replies
Feb 24, 2010
I have a UI that uses datagridviews / bindingsource / datatables of typed dataset for data entry. The dataset itself is serialized to a varbinary(max) in SQL. (i.e. no tableadapter, backend schema).I would like to limit the number of rows the user can enter into some of the grids (the data is used to fill PDF forms and I don't want them entering more rows than the forms can accomodate.).I have subclassed the datagridview, added a rowlimit property and tried to manipulate the AllUsertoAddRows property
Imports System.Windows.Forms
Public Class dgv
Inherits System.Windows.Forms.DataGridView[code]......
The behavior I see is that the messagebox comes up after leaving the max row even when the user is trying to leave the grid. I can lose the messagebox and deal with notification some other way but I thought someone else may have come up with something a little more sophisticated to handle simply causing attempting to add to many records to navigate out of the grid to the next UI control.
View 1 Replies
May 13, 2012
So far I have code for a textbox that limits the value entered by a user to two value places. However, I would like to limit the value entered by a user to numerical values only. And to handle any exceptions that go along with it.
View 2 Replies
Aug 6, 2010
I'm trying to check whether values ar between a maximum and a minimum limit. I do that 21 times, and it works 20 times. In case of the 21. time VB tells me that 15 is less than 8. Here the relevant lines of
[Code]...
View 5 Replies
May 3, 2010
I'm trying to limit the number of decimal values to 3 in numbers such as .3125 but I also have numbers such as .5 which I need to leave as is.
how can I determine if a number is 4 decimal places and cut off the last number.. I don't want to round up either.. .3125 should be .312 not .313 and .5 should stay at .5 and not .500.
View 19 Replies
May 3, 2012
I have a stored procedure (I cannot edit) that I am calling via linq.
The stored procedure returns values (more complex but important data below):
Customer Stock Item Date Price Priority Qty
--------------------------------------------------------
CUST1 TAP 01-04-2012 £30 30 1 - 30
CUST1 TAP 05-04-2012 £33 30 1 - 30
CUST1 TAP 01-04-2012 £29 20 31 - 99
CUST1 TAP 01-04-2012 £28 10 1 - 30
I am trying to limit this list to rows which have unique Dates and unique quantities in LINQ. I want to remove items with the HIGHER priority leaving rows with unique dates and qty's.
I have tried several group by's using Max and order by's but have not been able to get a result.
Is there any way to do this via linq?
EDIT:
Managed to convert brad-rem's answer into VB.net.
Syntax below if anyone needs it:
returnlist = (From p In returnlist
Order By p.Qty Ascending, p.Priority
Group By AllGrp = p.Date, p.Qty Into g = Group
Select g.First).ToList
View 1 Replies
Nov 1, 2010
I am still quite new to VB, and the whole OOP concept (Self-taught), I haven't coded in 30+ years, so I have a great deal to learn/relearn. I hope my ignorance is not too apparent.I'd like to set property values with the same names as the controls of a form to the value of the forms text (or checked or whatever) value. It appears that the 'Parent.Controls' statement below is doing what I want, but I can't seem to get this to work. I don't know if I should be using a structure for this, but I hope it demonstrates my intensions.
[Code]...
View 7 Replies
Jun 3, 2009
I'm writing a custom user control for my asp.net site, for storing datetimes. It has two properties:
Private _includeTime As Boolean
Private _value As DateTime = Nothing
Public Property IncludeTime() As Boolean
[code]....
I call my custom control in this way:
<my:DateTimeInput runat="server" includetime="true" ID="txtWhen" />
This sets the includetime property correctly.In my backend code I also do this on page_load:
txtWhen.SelectedDateTime = now
When I step through with the debugger, I see that the property gets set, BUT when the page_load of the control itself loads, the property value is reset to nothing!
The page_load of the control:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
lbltime.Visible = IncludeTime
If SelectedDateTime().CompareTo(Nothing) > 0 Then
[code]....
View 2 Replies
Aug 24, 2009
I have an abstract user control(baseModule) that has a property that I plan on using a bitwise comparison on to determine what export types are supported by that module. In the designer of a module derived from baseModule, I am presented with a combobox with the ability to just select a single value (Html, Xml, etc.) I would like to be presented with a drop-down checked listbox so I could select which values I want.How can I accomplish this inside of VS2008? I've seen other properties support this.
Public Class ExportTypes
Public Enum ExportType
Html = 1
Xml = 2[code]......
View 1 Replies
Dec 15, 2009
I have a class called Item which contains all the information about all parts, finished goods, in process parts (parts made on site), purchased parts, and raw materials.
I have a Bill of Materials table which has the following columns (reflected in the BOM class)
ParentItem
ChildItem
ChildItemQty
Parent Items can only be Items which have subcomponents.
Child Items can be parts that are made on site, purchased parts that are bought ready made from other companies, or raw materials used to make a part that is made on site.
Parent Items and child Items both inherit the Items class.
I will limit the Parent item class to only items that are in the parent column of the BOM table. I believe I can limit that by doing a quick look up on a view which only shows the parent items.
I will limit the Child Item Class to only items that are in the child column of the BOM table. Same method to limit it by doing a quick look up on a view that shows only the child items.
That way, an instance of the BOM class will have all the detail information about any of it's components available whenever I need them.
View 4 Replies
Apr 8, 2009
I'm trying to create a procedure that changes an items property value dynamically. [code]...
View 6 Replies
Jan 16, 2009
I need to set property values with WMI but it doesn't work. For example:
obj = New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem")
For Each objMgmt In obj.Get
objMgmt("description") = value
Next
That is supposed to set the computer description but it has no effects at all (and doesn't produce any exceptions). I can successfully retrieve value but I can't set it. The "description" property is supposed to be read and write, according to MS.
View 1 Replies
Jan 12, 2010
What is the difference between these two methods for defining property value defaults? [code] Is there a reason to use one method over the other for defining the default property values in a class?
View 24 Replies
Jul 13, 2010
I have class [code]...
But i get error in For Loop: Object reference not set to an instance of an object at the first line of for loop.
View 8 Replies
Jun 21, 2010
I have a custom control. I need to add a property, say, Comparison, to the control. The property should be set at design time using a dropdown. The Dropdown will have String values like '=','>','<' etc.
I tried using Enum values and working perfectly but I need to do some extra coding to convert the Enum values to the string I required. It would be great if I can get the values from the dropdown so that I can directly use the selcted value.
View 2 Replies
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
Nov 12, 2009
I am programatically creating instance of usercontrol as shown below
[code]...
I have two public properties in my usercontorl like clerkName and RespName. How can I set those values in the above code. Intellisense is not showing ClerkName and respName Properties.
View 1 Replies
May 4, 2012
I am programmer from some time only, I have certain doubts in fundamentals, could you please clarify on the following:Case 1:
[Code]...
Does case 1 and case 2 yield same result, I mean is a private value necessarily in there?, can we use property itself to use its own value in its Set and get statements?
View 2 Replies
Feb 21, 2010
I thought I saw how to do this but can't seem to find it now.Is there a way to set the properties of all controls on a Form by Control Type?Meaning, if I have 5 textboxes on a form can I write code like .If page.contol is TextBox then
textbox.forecolor = Blue
Then when the page loads is sets all the textboxes forecolor on the form to Blue.
View 8 Replies
Sep 1, 2009
I'm trying to create an export Excel/CSV function that will iterate through a custom object and first output the property names and then output the values. I want to use reflection only where necessary so I'm attempting to save the property names when I output the headers and then reuse them to print the values. Is this possible? I'm a little weary of using reflection in a loop but is there a better way?
[Code]...
View 2 Replies
Mar 23, 2011
Is it possible to (or how can I) assign values to a class property array like this:
MyImgClass.RGB = (255,255,255)
I'm not sure how to build my Public Property setter to allow this, if it's possible at all.
View 4 Replies
Oct 1, 2011
I am trying to use several Class arrays to hold values that I will cycle through at a later point to perform some calculations. I need to change the array sizes to fit the data as it is entered. I am using one procedure to set the first element of each array and then a separate procedure to pass the additional values as they are entered.
Until my last attempt at changing my code, my StartBalance sub seemed to work, I could step through and see the values assigned to the class arrays in the code block. However, when it moved on to the Transaction sub, it did not recognize that the first set of values were set, the array shows zero values for index 1.
I have gone through several changes trying different ideas from reading blogs and articles, but I guess I am not understanding how these work. I even used the class arrays directly instead of the Property procedures to see if I would get a different result, but I do not.
I believe I must be approaching this incorrectly and though I can find dozens of examples of setting class variables and even a couple on using arrays as class variable, I can not find any that show how to then pass values to those arrays.
Public Class Statement
Private _tranDate(1) As Date
Private _amount(1) As Double
[Code]....
View 8 Replies
Jun 21, 2010
I have valued pairs, attributes names and values in one hand, and I have an object with attributes. I need to set the values of those attributes. I need something like [code]
View 1 Replies
Apr 18, 2011
I've mainly been recording keystrok macros... I created visual basic code that allows the user of a template to hide table gridlines - which works fine. The code to show gridlines does not work if the table has only one row. Here is the code - it is getting "stuck" on the
.LineWidth = wd
LineWidth050pt for a horizontal border, as there isn't one. I don't know how to change the code to not execute the command if a horizontal border line does not exist.
With Selection.tables(1)
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = 5592405
[Code] .....
View 2 Replies
Apr 1, 2010
Can any one tell me how to read or write the control property values that has been saved as ocx state value in the XML? I have some controls. I am assigning a property values for that controls and it is saving as binary64 format. I need to automatically assign property values in the binary64 format in xml.
View 1 Replies
Jan 8, 2010
I've created a custom user control that has several properties. One specifies which database I want the control to access. I want to be able to present the user of the control a drop down from which he can select which database the control will interact with. How do I get the dropdown to work? I can get default values, but have yet to figure out how to get the selectable list.
View 4 Replies
Apr 4, 2012
The problem is: I have a list of objects, with some containing the same PlanId property value. I want to only grab the first occurrence of those and ignore the next object with that PlanId. The root problem is a View in the database, but it's tied in everywhere and I don't know if changing it will break a ton of stuff nearing a deadline.
So, if I have a list of PlanObjects like such.
Plan1.PlanId = 1
Plan2.PlanId = 1
Plan3.PlanId = 2
Plan4.PlanId = 3
Plan5.PlanId = 4
Plan6.PlanId = 4
I want to take a sub-list from that with LINQ (italics mean an item is not included)
Plan1.PlanId = 1
Plan2.PlanId = 1
Plan3.PlanId = 2
Plan4.PlanId = 3
Plan5.PlanId = 4
Plan6.PlanId = 4
For my needs, it doesn't matter which one is taken first. The Id is used to update a datsbase record.
View 1 Replies
Dec 9, 2011
I'm having some very weird issues with interfaces right now.
I have a very simple setup. In one of my class, I have a Property implementing a Property from an Interface.
In my class it's like:
Private _oForm As IForm
Public Property Form As IForm Implements IContainer.Form
Set(value As IForm)
[Code]...
I have like dozens of interfaces like this working throughout my project and I can't believe this simple one can't work!
View 1 Replies