|
balaji_vbr wrote: using ftp / web client methods using threads to upload a file
If you are using the asynchronous method like UploadFileAsync() , I believe there is a CancelAsync method too which can cancel the operation.
|
|
|
|
|
I was hoping one of you clever people could me a hand...
I have a form with an array of class "myObject" that holds my data and I want to show the array in a ListBox control that will display the Name property. When the user clicks on an item in the list the details of that item are displayed in some TextBox controls. The user can now edit the data when they are done they click a button that will update the array and if needed the display name in the list. or even reflect changes straight into the array
How do I databind my object array like a database table? I've tried reading the MSDN on ListBox Control Overview (Windows Forms) but it isn't very clear/only talks about databases.
Not understanding this small area is really holding back my .NET work
I did find this[^] while I was looking but it only covers using a DataSet from a DB.
Dave Henry
-----------------------------------------
evil mastermind or genius benefactor?
NEVER trust the bunny...
modified on Sunday, July 6, 2008 4:15 PM
|
|
|
|
|
You probably will want to use Collection instead of array for binding to listbox.
1. For the display of object in the listbox, override ToString() to display the value that you want on the listbox.
2. Implement INotifyCollectionChanged and INotifyPropertyChanged.
|
|
|
|
|
I forgot to say that I'm using .NET 2.0
Also what do you mean a collection? something like List<myObject>> ?
I'm using the array object because I know that I can easily serialize the array to/from a file.
Dave Henry
-----------------------------------------
evil mastermind or genius benefactor?
NEVER trust the bunny...
|
|
|
|
|
Collection is in .NET since at least 1.1.
You can probably use List<t> for the same purpose though I have not tried that before.
CollectionBase[^]
|
|
|
|
|
either way I still don't know how to data bind the Array/List/Collection to my list box displaying the name property and allow edits from my TextBoxes
public class myObject
{
public string Name;
public string Company;
public string Title;
public string Phone;
}
In the form:-
private myObject[] bodList = new myObject[5]();
I want an GUI that looks like this[^], the same functionality just using my object and NOT a DB connection.
Dave Henry
-----------------------------------------
evil mastermind or genius benefactor?
NEVER trust the bunny...
|
|
|
|
|
Do you mean the databinding of the textboxes? There's no quick way to do that.
The right panel with a textbox is a form or custom control that has a public property of myObject.
1. In the setter, check for null, if null, disable all textbox and clear all text.
2. If not null, that means an object is already bound to the form/custom control. Clear all the databinding of textbox, then set the databinding of the textboxes to the properties of the new object, accordingly.
On the listbox end, when there's a selected index changed, get the selected object from the listbox, and set it to the form/custom control public property.
|
|
|
|
|
After a bit of searching I found This[^] which explained how to use a BindingSource object to bind together all the controls.
The only thing was in the article he adds each reference with the add method on BindingSource instead I just set the DataSource to my array.
Using this method to populate a listbox you get a list showing the object name until you set the DisplayMember to a property name. Also BindingSource only shows properties so my class of public fields didn't work I had to make them all private alter the name and add a public getter and setter with the names i was using elsewhere in my code. But now my textboxes are bound to the array and display whatever is selected in my listbox .
Job Done.
Dave Henry
-----------------------------------------
evil mastermind or genius benefactor?
NEVER trust the bunny...
|
|
|
|
|
In my project i want to implement sound recording what we have in windows xp so i want consume that.
Give me suggestion how to implement recording sound in .net any dll is avliable?
help me out
Ashok Nalam
|
|
|
|
|
Don't post in multiple forums, it's rude.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Hi,
I have to excute my own functionality while closing the windows form.
but its always firing formclosing event (I can not use formclosing event as I am using this to navigate to other forms)
Finally, Please help me to solve, how to excute functionality of MyOwn Button while closing using ControlBox's X Button
Thanks,
Prashanth
|
|
|
|
|
Call MyOwn Button's event handler in formclosing event.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Thanks for your help Mr.Giorgi Dalakishvili,
But that won't solve my Problem,
See, I am not using MDI.
I have Main Form which contains Exit,Form1 and few other buttons, and my functionality to close the application is written in exit button.
But when user clicks any other button say,Form1 to go Form1, Since The Main Forms Close event also calling at that time the Main Form too closing not my application(So all the threads and timers that I wrote in exit button are not ending)
I just want to know how to call my exit button functinality Only when user clicks ControlBox's X Button.
Thanks,For ur Time
Pashi
|
|
|
|
|
Your post is quite unclear but from what I guess that when you click Form1, your main form is closing. Why do you do that? Just show Form1.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Thanks Again For your reply,
say I am in Main Form Now.
After I click on Form1 Button of Main Form, Main Form's Closing event is calling and since the in the ControlBox 'X' Button is also calling Main Form's Closing event for Main form the application is closing.
So, I just want to know do I have any alternate so that, I can catch the form Closing Event
I mean whether the process is entering into form closing event by ControlBox's 'X' click or
while redirecting to any other form.
Hope you got my point now!
Thanks again for ur time
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Maybe a CloseReason property of a FormClosingEventArgs object which passed by a Closing event is what are you looking for.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
The pages have been done with a 1280 x 1024 resolution. I am currently using it on a laptop having 1440 x 900, and unfortunately I can not reach the previous next button placed on the bottom of the page without scrolling down each time.
Is there any way, that i can set the properties of form such that it will make the form size as per windows pixel values.
|
|
|
|
|
The dock and anchor properties can be set to make a form resize itself cleanly.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
yes you r right that dock property is being use to resizing the control, but i m currently using the FORM not controls, my form is not getting resized accordingly and form is not having any dock property.
and i have made autosize property of form to grow and shrink.
can you guide me for this.
Thanks
|
|
|
|
|
Hi,
you can set your Form's Size at Load time using your monitor's Size; have a look at
either the Screen class or SystemInformation.PrimaryMonitorSize
|
|
|
|
|
I'm having intermitent problems with my winforms app since I added a System.IO.Ports.SerialPort object to receive strings from the serial port, then write those strings to the database.
I know that because of cross-threading exceptions, if I want to update any control on my form, I need to update it from that control's invoke method. I'm fine with that.
But what if I want to execute a method of an object that doesn't inherit from Windows.Forms.Control, and therefore doesn't have an Invoke method?
For example
DataAccessLayer dal;
IO.Ports.SerialPort port;
string portBuffer;
private void frmMain_Load(object sender, EventArgs e)
{
dal = new DataAccessLayer();
port = new IO.Ports.SerialPort();
}
void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
portBuffer += port.ReadExisting();
if (portBuffer.Contains("OK"))
dal.InsertStringIntoDatabase(portBuffer);
}
Does the 'dal' object run on a different thread from the 'port' object? If so, must I write a custom BeginInvoke, Invoke method for the 'dal' object. The dal object does not inherit from Control.
Thanks
|
|
|
|
|
This should work just fine. I have threads sharing objects that are non UI all the time,
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
I may be wrong, I don't do a lot of thread work however as you are declaring the dal and port objects in the main thread where is the additional thread involved.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I want to store subscript and superscript like H20, H2SO4, 6th in sql server and also vb.net windows application also..
i'm using vb.net2005 ..
Please help me.........
Bye
K.Mani
kanmani84@gmail.com
By
K.mani
|
|
|
|
|
You asked the same question just yesterday and also in VB.NET forum.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|