PlausiblyDamp
Administrators-
Posts
7016 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by PlausiblyDamp
-
Here we go ;) Imports System.Web.UI Imports System.Web.UI.HtmlControls Imports System.Web.UI.WebControls Public Class BoxList Inherits System.Web.UI.WebControls.WebControl Implements IPostBackDataHandler 'we need to handle postback ourselves Implements INamingContainer ' generate unique names for child controls 'array of textboxes our control will contain Dim TextBoxes() As TextBox Public Property BoxCount() As Integer 'Store property in viewstate Get Return Convert.ToInt32(ViewState("BoxCount")) End Get Set(ByVal Value As Integer) viewstate("BoxCount") = Value.ToString End Set End Property Public Property Data(ByVal Index As Integer) As String 'Store property in ViewState Get Return ViewState("Data" & Index).ToString End Get Set(ByVal Value As String) ViewState("Data" & Index) = Value End Set End Property #Region " RENDER " Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter) Dim iBox As Integer AddAttributesToRender(output) output.RenderBeginTag(HtmlTextWriterTag.Table) 'Table For iBox = 0 To BoxCount - 1 output.RenderBeginTag(HtmlTextWriterTag.Tr) output.RenderBeginTag(HtmlTextWriterTag.Td) With TextBoxes(iBox) .Text = Data(iBox) .ID = "TextBox" & iBox .Width = Me.Width .RenderControl(output) End With output.RenderEndTag() 'td output.RenderEndTag() 'tr Next output.RenderEndTag() 'table End Sub #End Region 'Dummy C'to for now Sub New() BoxCount = 6 ReDim TextBoxes(BoxCount - 1) End Sub Public Function LoadPostData(ByVal postDataKey As String, ByVal postCollection As System.Collections.Specialized.NameValueCollection) As Boolean _ Implements System.Web.UI.IPostBackDataHandler.LoadPostData 'Never Gets fired Dim i As Integer For i = 0 To BoxCount - 1 'only update the viewstate if things have changed If ViewState("Data" & i).ToString <> postCollection(TextBoxes(i).UniqueID) Then ViewState("Data" & i) = postCollection.Item(TextBoxes(i).UniqueID) End If Next End Function Public Sub RaisePostDataChangedEvent() Implements System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent End Sub Protected Overrides Sub OnInit(ByVal e As System.EventArgs) Page.RegisterRequiresPostBack(Me) 'notify framework we need postback notification MyBase.OnInit(e) Dim i As Integer 'create our controls.... For i = 0 To BoxCount - 1 TextBoxes(i) = New TextBox TextBoxes(i).ID = "TextBox" & i Me.Controls.Add(TextBoxes(i)) Next End Sub End Class seems to work under very casual testing. In reality should have a few more error traps etc. Let me know if it solves your problem / doesn't solve your problem / fails utterly in every respect and I can have another look / feel really glad I recently decided to learn asp.net server controls ;)
-
It's not directly accessing a non-shared member though - it's creating a new instance, which calls the new instance's constructor as normal.
-
You may want to have a look at Caching as part of the asp.net framework. see also http://support.microsoft.com/default.aspx?scid=kb;en-us;323290
-
Try to avoid END as it doesn't always close resources down correctly - as a rule if you have to use End to get your app to exit then you are failing to close your own resources down.
-
It looks like a lot of VB6 code that hasn't been ported to .Net properly. Functions like Left, right will fail because the need to be refered as Microsoft.Visualbasic.Left etc. In fact they are really only there for compatability and should be replaced with the .Net equivalents (Substring will replace both). Also all the conversion functions should use the .Net equivalents rather then the VB6 ones - CShort etc
-
Is there any code in the form_load or form_activated events that change the form's size? When you rebuild the app do you get any errors generated?
-
Just had another thought - will investigate more tomorrow. But do you need to be involved with the LoadViewstate / saveviewstate yourself - that would normally only be required if you are persisting complex data types - would you not be able to just store the values direct into ViewState?
-
Odd indeed, have had a quick look but can't see anything obvious - then again it's getting late.... Will have more time to have a look tomorrow though. If you find anything post here - if not I'll see what I can do tomorrow. Just out of interest have you looked at implementing an overrided TrackViewState - can't remember exactly if this will help but IIRC it does help to track modified ViewState entries.
-
Any chance you could post the relevant code (LoadPostData, RaisePostBackEvent, LoadViewState, SaveViewState and TrackViewState)
-
To detect a key you can use Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress If e.KeyChar = "_" Then 'will get the _ key End If End Sub To get the ascii value you can use Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress Dim b() As Byte = System.Text.Encoding.ASCII.GetBytes(e.KeyChar) 'b(0) will now equal the ascii code End Sub
-
Loading a layout from an XML file is fairly easy - however this would not introduce a new form class into the executable which is what the question would seem to be refering to. If there is a need to load forms dynamically there are ways to achieve this (reflection being a good one). XML will allow you to alter the layout but would give no easy way to provide code / event handling as far as I'm aware.
-
Any reason why you want to do it this way? After all all the form names are compiled into your exe anyway so you will need a recompile to change / add a form..... But here is one possible way Dim s As String = "WindowsApplication1.Form3" Dim f As Form Dim fType As Type = Type.GetType(s) f = System.Activator.CreateInstance(fType) f.Show()
-
It's a function call - it has to be called as part of another procedure, just leaving it in the declarations section breaks the syntax of the language.
-
Multiple users accessing DB?
PlausiblyDamp replied to dakota97's topic in Database / XML / Reporting
Most modern DBs will provide in-built controls to prevent conflicting updates (mainly through the use of locks). Two people updating different tables isn't normally a problem - neither is two people updating the same table (as long as it's not the same record). Out of interest what database are you planning on using? -
you did put it in the Form's load event didn't you?
-
IIRC Visual Studio.Net 2002 only targets the 1.0 framework, you will need to upgrade to VS.Net 2003 to be able to compile against the 1.1 Framework.
-
The problem is .Read() takes the next character from the input - including The CRLF pair. e.g. If you type 1 then 2 the buffer will be userInput[0] = '1' //byte 49 userInput[1] = //byte 13 userInput[2] = //byte 10 userInput[3] = '2' //byte 50. as NK2000 suggested use readline as this handles the CRLF automatically.
-
adding binary value to registry
PlausiblyDamp replied to tommy916's topic in Directory / File IO / Registry
Dim rk As Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\Test") Dim b() As Byte = {1, 2, 3, 4, 5, 6} rk.SetValue("A Value", b) will write out a simple byte array. -
try Public Function FoundMatch() As Boolean For Each s As String In ListBox1.Items If ListBox2.Items.IndexOf(s) > 0 Then Return True End If Next Return False End Function
-
You would probably have to check based on a timer - if there is a newer version then start the update process and exit, let the update complete and force the app to restart.
-
Public.. Private...Static... Variable Scopes
PlausiblyDamp replied to ThePentiumGuy's topic in General
The enumeration needs to be public in this case - if the structure is public and it refered to a private data type how would calling code know how to use the enumeration? It may helkp if you gave a bit more information on why you need this, there may be another means to implement it. -
http://windowsforms.net/articles/appupdater.aspx
-
http://www.xtremedotnettalk.com/showthread.php?s=&threadid=49315&highlight=bootstrap+dotnetfx
-
What is the name of the form this sub is in? If it is frmCP then you could do either Private Sub mnuDefaultCpanel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDefaultCpanel.Click cmdLaunch_Click() End Sub or Private Sub mnuDefaultCpanel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDefaultCpanel.Click Me.cmdLaunch_Click() End Sub
-
Just double up the ampersand i.e. &&