|
You need to 'shadow' the BorderStyle property in your control, then set property attributes to hide it from the VS property editor, e.g.
<Browsable(False), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Public Shadows Property BorderStyle() As BorderStyle
Get
Return MyBase.BorderStyle
End Get
Set(ByVal value As BorderStyle)
MyBase.BorderStyle = value
End Set
End Property
The Browsable attributes hides the property from the VS editor, the DesignerSerializationVisibility atrtibute stop the VS designer generating code for the property in the InitialiseComponent method. You need to use the Shadows keyword in the property def to stop the compiler generating a warning.
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Thanks a lot dear! its working fine.
|
|
|
|
|
Please tell me one thing. how can i add summary detail for my user control property? the way you can see for anyother property and methods and even for events in objectbrowser.
|
|
|
|
|
Hi, use the Description attribute. You may also want to check out the Category and DefaultValue attributes, e.g.
<Description("example property"), DefaultValue(1), Category("Testing")>
All these attributes are in the System.ComponentModel namespace
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
hi to all,
I want to get last inserted id from a particular table,
how i write the sql query.....
|
|
|
|
|
Normally, you wouldn't do this at all. You let the database keep track of and assign the ID itself when you create a record.
Why? Well, say you have 2 clients accessing the database at the same time. They both execute that little function that returns the last ID used and they both get the same ID number. Then, they both generate the next logical ID number and try to use it. Boom. You either just corrupted your data because you don't have any constraints on the key column or you just got an exception thrown back in your face about using the same key more than one in a table.
|
|
|
|
|
Although you have 3 remarkable haphazard in your example, but they are acceptable
Every table should have unique key (PK), that key is usually an Autoinc field type, when insert new record, the table will automatically generate the next ID to be used for the next client.
But very often, you need to make your own sequence number need to be written in the table, and you can usually do that by creating a table (numbering) which store in it the next ID for (let say new invoice) and you can luck this record and prevent any one from accessing this record and the user get his ID and unlock the row.
My point is, you will not let the database generate new ID for you in every situation.
Samir R. Ibrahim
modified on Friday, February 13, 2009 7:50 AM
|
|
|
|
|
True, but locking records manually is VERY problematic if not done with the utmost of care. Most newbies asking questions around here have no idea what they're doing, so using a solution like this is going to be beyond them.
|
|
|
|
|
I understood what you want to say.
Regards.
Samir R. Ibrahim
|
|
|
|
|
What has that to do with VB.Net?
SELECT @@IDENTITY returns the last inserted primary key.
|
|
|
|
|
I have an application in which i want to run multiple threads periodically.For this i am using the system.threading.timer in an array.
When i start the timer i also want to pass a string as a parameter to the timer callback method.There is a parameter; 'state as object'.Can i pass the the string through this?
For j As Integer = 0 To m_TimerList.Count - 1
'Dim oCallback As New TimerCallback(AddressOf timer1_tick)
Dim s As String = "1"
m_TimerList(j) = New System.Threading.Timer(m_Timercallbacklist(j), New Object() {s}, 1, 5000)
k = k + 1
Next
How do i get the string in the timer callback method 'timer1_tick'
|
|
|
|
|
|
I am still not getting it...dont know how to adapt the example for my case.
Private Sub timer1_tick(ByVal state As Object)
Dim j As String = DirectCast(state, String)
End Sub
this gives an error.
|
|
|
|
|
Ok, what error, an invalid cast exception maybe? I don't programme in VB but I think the answer may be to pass s directly not as New Object() {s}.
m_TimerList(j) = New System.Threading.Timer(m_Timercallbacklist(j), s, 1, 5000)
Alan.
|
|
|
|
|
thanks alot.that worked,
Dim s as string
m_TimerList(j) = New System.Threading.Timer(m_Timercallbacklist(j), s, 1, 5000)
in the timer callback method...
Private Sub timer1_tick(ByVal state As Object)
Dim st As String = state
End Sub
NO casting...what is it used for anyway?
|
|
|
|
|
It is used for when you have Option Strict on (which you should turn on by default in the Options menu)
|
|
|
|
|
Glad the problem is sorted now. The compiler has done an implicit cast of Object to String but if you were to specify "Option Strict On" in your code you would have had to explicitly code the cast.
It's not a bad idea to code with strict on as it forces you to state your intentions more precisely, i.e. this parameter of type Object is actually a String and must not be anything else. The explicit cast does that for you.
Many implicit conversions will succeed and then you can be left with a major problem debugging difficult to comprehend logic errors in your code. Option Strict On will stop many of these errors before they happen and make your code more reliable.
Alan.
|
|
|
|
|
As I am in need to stop reading the barcode scanner,please give me the code to stop (disable ) and enable the serial port.
I expect the detailed code, since I am beginner in this area of VB.Net
-Noufi
|
|
|
|
|
I can't tell from your post whether you have written code to access the serial port.
If you haven't then read up on the System.IO.Ports namespace and come back with specific problems in your code.
If you just want general help on the serial port and example code then a quick search on Google will get you started.
Alan.
|
|
|
|
|
Noufe wrote: As I am in need to stop reading the barcode scanner,please give me the code to stop (disable ) and enable the serial port.
First, write you own code. You don't disable the serial port. You simply close the port your opened. This will keep you from reading any more data on the port until you open it again.
Noufe wrote: I expect the detailed code, since I am beginner in this area of VB.Net
You "EXPECT"? Ballsy, real ballsy. Don't start making demands in a forum environment. Epsecially since you're not paying for support and we all volunteer our time here.
|
|
|
|
|
I need to use one report with subreport i am using .Net Reporting.
The report is working without parameter from Master report to Sub Report
But when i pass the parameter to sub Report then it Give Error.
Is There Any Example or Tips Then Thanks
Best Regards,
Chetan Patel
|
|
|
|
|
Copy and paste your report to Bin/Debug Folder for the latest copy of the report because the application is running from that folder
Best Regards,
Chetan Patel
|
|
|
|
|
Hi all
I am comming from VFP environment, and I work most of my project in VFP in addition to some project in vb6 and now in vb.net
In VFP there is no OPTION EXPLICIT, which mean There is no Strongly Type variable available so can code something like
oIE = Createobject("InternetExplorer.Application"
cName = "Soemthing"
cName = 10
The small "c" is for Character, "o" for Object, "c" tells that the variable cName is character type variable.
Since in vb6 and vb.net are strongly Typed language, I have 2 question
#1 Is it best practice to use Variable Naming? or that is not important?
#2 if yes, what is the best Variable Name Technique?
TIA
Samir R. Ibrahim
|
|
|
|
|
Adding Prefix is good practice.
In .net It is best if you give proper name like
DateOfBirth instead of DOB
Initail Capital
And add First caracter for DataType means
dtDateOfBirth
Best Regards,
Chetan Patel
|
|
|
|
|
Chetan Patel wrote: Initail Capital
And add First caracter for DataType means
dtDateOfBirth
Hi Chetan.
That looks like a good way to follow.
Is there is a list for what prefix I should use for all kind of variables type?
Samir R. Ibrahim
|
|
|
|