Jump to content
Xtreme .Net Talk

PlausiblyDamp

Administrators
  • Posts

    7016
  • Joined

  • Last visited

Everything posted by PlausiblyDamp

  1. using System; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class SampleControl : UserControl { public EventHandler SampleEventHandler; public event ScrollEventHandler SampleEvent; protected void OnSampleEvent(SampleChangedEventArgs e) { if (SampleEvent != null) SampleEventHandler(this, e); } public SampleControl() { InitializeComponent(); } private void textBox_TextChanged(object sender, EventArgs e) { OnSampleEvent(new SampleChangedEventArgs {NewValue = 1}); } } public class SampleChangedEventArgs : EventArgs { public int NewValue { get; set; } } } That should give you an idea of what the custom control should look like - you just need to make sure the TextChanged even for both textboxes is assigned to the textbox_changed event handler.
  2. The easiest way would be for the custom control to define and raise it's own event when the result of textbox1 + textbox2 changes. Within the control you would have a single event handler that handles the TextChanged event for both textboxes and would raise the control's custom event if the value changes. The form would then handle the control's event and would update the content of the third textbox from within this event handler.
  3. Is there a specific problem you are having with the converted code?
  4. It looks like the converter is being tripped up by some of the differences between c# and vb.net. Try Imports System.Threading Imports System.ComponentModel Namespace SynchronizationContextExample Public Class MySynchronizedClass Private workerThread As Thread Private operation As AsyncOperation Public Event SomethingHappened As EventHandler Public Sub New() operation = AsyncOperationManager.CreateOperation(Nothing) workerThread = New Thread(New ThreadStart(AddressOf DoWork)) workerThread.Start() End Sub Private Sub DoWork() operation.Post(New SendOrPostCallback(Sub(state As Object) RaiseEvent SomethingHappened(Me, EventArgs.Empty) End Sub), Nothing) operation.OperationCompleted() End Sub End Class End Namespace and see if that works (I think it will require .Net 4 though because of the use of a sub rather than a function for a lambda expression).
  5. Out of interest why are you loading these values into textboxes anyway? Could you not just read a line from the file, split it into it's 4 parts and then add the point to the chart and then read the next line etc? I am assuming you already have the code to read the lines and the code to split a line so I am unsure why there is the extra steps involving populating textbox controls.
  6. http://support.microsoft.com/kb/841291 should give you an idea of what to do.
  7. If it isn't a .net or a com dll then you don't need to add it as a reference to the project, you would just need to include it in the project properties -> publish tab.
  8. If you set a reference to "copy local" it simply means a copy the the dll will be included in the folder containing the executable. You should be able to add the dll to the clickonce package, if you bring up the properties for the project in visual studio and go to the publish tab you should be able to add the .dll in as a required file - this means it will be deployed by click once automatically. Sometimes files were dumped into system32 as a way of making them available to the entire system, if it is only needed by one app then it might work if it is contained in the same folder as the .exe itself.
  9. Have you tried putting the dll in the same folder as the application and listing it as a required file under the clickonce property page?
  10. Clickonce applications are designed to be a "low impact" deployment and as such are installed per-user rather than per-machine as this doesn't require any administrative permissions. Modifying the System32 folder however requires administrator permissions and is a per-machine wide change. If you need to deploy things to a central location clickonce is probably not the technology to use, can you not just deploy this dll alongside the application itself?
  11. Re: Listview ( remove item ) in vb.net? Not entirely sure what your question is - are you trying to get the index or the item the index refers to? If you are after the index then what problem are you having?
  12. As the intellisense is indicating, you can only add a string or a ListItem to the DropDownList.Items collection. You should however be able to store the cboAddItem objects in a collection (such as a List(Of cboAddItem) and data bind to this collection.
  13. There is a hotfox mentioned in http://blog.paulbetts.org/index.php/2010/07/20/the-case-of-the-disappearing-onload-exception-user-mode-callback-exceptions-in-x64/ looks like this is the only option till Win7 Sp1 is released.
  14. There is a known issue with the 64 bit version of the framework were exceptions thrown in a form load get skipped over, I will try to dig up the KB article if I can. Unless you need a 64 bit app you could try setting the project to build as x86 and see if that helps.
  15. Are you running on a 64bit version of windows?
  16. Is there any other information displayed? If you try a debug build does the exception contain any other details?
  17. You would probably need to use various WinAPI calls to make this work. Firstly you would need to identify the relevant text boxes (FindWindowEx is probably the one to use), then attempt to set the text of the various controls (SendMessage is the one for this) and then you would need to simulate the button click (again IIRC SendMessage can also do this). This is not going to be a trivial task however and it might be easier to see if you can find a tool that already provides this functionality. Personally I would split the actual logic out from the form itself and have the button click event simply call methods defined in a separate class(es), this class(es) could then have a set of unit tests written which are far easier to automate and require no UI interaction.
  18. The code you have in the form_Load will work just fine, however it will only run when the form loads, if you want it to update every time you add something to the list you could just add that code to the end of Button1's Click event.
  19. In the line of code if (a.Item) you are trying to access a member of the variable a with the name Item, the underlying structure Item doesn't expose a method or property called Item however. The line of code public Item(string status, string title, string series, string author, string type, string description) defines a constructor for the Item structure, this is used when you create a new instance of Item and is never called directly however.
  20. I take it you mean the idea of exposing variables as public rather than using properties... The problem with public variables is the fact they can be modified from anywhere in the application with no restriction or validation whatsoever. If you declare the field as a property then you could perform validation in the set part to ensure any values assigned are valid or simply omit the set entirely to make the property read only and only allow changes through appropriate public methods. This effectively gives you more control over where changes to these variables can be made, allowing you to implement and validation or associated logic in one single place rather than multiple times throughout an application.
  21. To populate the listbox you could either set it's DataSource property to the array and then call .DataBind() on it or simply loop over the array and add each item to the listbox in turn.
  22. Rather than thinking of this as "sorting a session" or "sorting a listbox" you really want to get a simple routine working that can sort a list of integers, this doesn't even need to be done in the context of a web application. Once you get this working you can use your web application to populate an array that you would store in the Session between post backs, the list box would just display the contents of this array.
  23. Is there a reason you are sorting the list manually? It would be far easier to use Array.Sort and let .Net do the hard work for you. http://msdn.microsoft.com/en-us/library/ms178581.aspx explains Session state and might be a better alternative to the view state.
  24. You really should treat the UI as a way of interacting with the user, i.e. displaying information or gathering information, but nothing more. When the user enters a value and hits the Add button it should be adding the value to the array or collection you are using behind the scenes (I would personally use a generic collection rather than an array) and then this list used to populate the listbox. As you are working in a web environment you need to be aware that web pages are inherently stateless - information is not retained between page refreshes automatically and you will need to deal with this yourself (it may be worth looking at the Session object for a starting point). The code FastestSort(lbList(min, max)) is attempting to treat the lbList as a two dimensional array and then pass it to the FastestSort routine - hence the error.
  25. If you put a break point on that line and run it, what are the contents of the variable i, lbList and lbList(i)?
×
×
  • Create New...