|
If you add Customer to listbox, it just copies reference to that customer.
When listbox displays the customer, first it checks if you set "DisplayMember" to display, if you did, it will display that property. If not, it will call "ToString()" on the object to display it.
IF you override ToString() on customer, you'd see in the listbox whathever you return from that method.
Or implement properties on Customer (getter method) and set DisplayMember to the name of that property.
You should add Customer to the list, then you can cast that object:
Customer cust = new ....;
listbox.Items.Add(cust);
...
Customer selectedCust = (Customer)listbox.SelectedItem;
to get first name, in customer have:
public string FirstName
{
get{ return this.firstName; }
}
and in Form1() constructor (below initialize)
listbox.DisplayMember = "FirstName";
and now just add customers to the listbox.
|
|
|
|
|
OK, I got it now. I'm alot smarter now too. Thanks for your help.
/\ |_ E X E GG
|
|
|
|
|
Hi guys
I was wondering if it's possible to use Microsoft Visual C# Standard edition for commercial in-house development? I only want Visual C# (preferrably Professional edition) but I don't want to fork out the extra cash to buy the whole VS.NET 2003 Professional.
|
|
|
|
|
Yes, the only one you can't do that with is the student edition.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Thanks for your help. Now I can save AUD$1500 and still develop commercially! Yay!
|
|
|
|
|
Hello,
I'd like to have a small gradient panel on the top of my application. I created a Custom Control and added this to OnPaint:
ColorBlend cBlend = new ColorBlend(2);
Color[] blendColors = {this.BackColor, SystemColors.ActiveBorder};
float[] pos = {.0f, 1f};
cBlend.Colors = blendColors;
cBlend.Positions = pos;
LinearGradientBrush brush = new LinearGradientBrush(e.ClipRectangle, blendColors[0], blendColors[1], LinearGradientMode.Horizontal);
brush.InterpolationColors = cBlend;
e.Graphics.Clear(this.BackColor);
e.Graphics.FillRectangle(brush, e.ClipRectangle);
It works nicely. But when I resize, I think it only repaint the a small part of the area, which makes it look odd.
Tried to catch the resize event, and did this:
Invalidate(this.ClientRectangle, false);
But apparantly, that wasn't enough.
Any ideas?
|
|
|
|
|
Don't use e.ClipRectangle for the area to fill (and the LinearGradientBrush) but this.ClientRectangle .
Then you can even remove your Resize event handler.
You should set the ResizeRedraw ControlStyle, though.
Regards,
mav
|
|
|
|
|
Hey.
How can i get the total machine RAM, ram used, etc?
Api?
Thanks.
|
|
|
|
|
using System.Management and then a PerformanceCounter
This is how I did it once... (Free Memory)
public int GetAvailableMemory()
{
PerformanceCounter ramCounter;
ramCounter = new PerformanceCounter("Memory", "Available MBytes");
int a=Convert.ToInt32(ramCounter.NextValue());
return a;
}
/\ |_ E X E GG
|
|
|
|
|
Also look for WMI articles in C# section in this site for other solution.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
Maybe try checking the Environment Values. I think you can access them using the System.Environment namespace. It gives you access to all sorts of info, like OS version, current directory, and WorkingSet(I think this is mach ram).
Hope this helps 
|
|
|
|
|
My app is built on a model/view/controller pattern, which makes more sense when I'm not using the keyboard ( this app has 5 different controller classes, the keyboard one is only used for testing ). The keyboard controller exposes a keyboard event handler, which is subscribed to the OnKeyDown in the view, the view obvioulsy being a Form that has keyboard focus. This has worked fine for ages, in fact the app is nearly done. But on the weekend, the controller stopped recieving messages for the arrow keys, so I've had to map to i/j/k/m ( the first standby of any old Apple ][ coder ). It's got me beat how this could happen though, does anyone have any ideas ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
You can catch arrow key event in a form or custom control by overriding ProcessCmdKey method.
Under some circumstances (i'm not sure when) OnKeyDown/Up doesn't get called on arrow key events.
|
|
|
|
|
Thanks, I'll try that.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
i need to study differntial comparison algorithm for images using c#. where can i find material for that.
sho123
|
|
|
|
|
Look at my image processing articles for code on how to get to the bits of an image, then I guess you need to decide exactly how you intend to compare that data.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
may i noe where can find yr image processin articles?
|
|
|
|
|
Sure. They are right here, on Code Project. Just search for my name or 'image processing' in the search box.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
hi all,
I'm facing a problem while redirecting from one page to another using the Server.Transfer() method.
I understand that when using Server.Transfer the url in the address bar would remain the same, but thats not the case in my application.
i use the following code in my homepage (FirstPage.aspx)
Server.Transfer("SecondPage.aspx",true);
so, when redirected from the first page to the secondpage, the url in the address bar remains as "FirstPage.aspx".....i'm happy so far.
but, in my second page i have certain postback events like selecting a value from a dropdownlist.
here's where the problem arises. With the post back event the url in the address bar turns to "SecondPage.aspx"
?????
what do i do to keep the url in the address bar static?
i prefer the url in the address bar to remain as "FirstPage.aspx" through out the whole application.
Could some one please guide me
|
|
|
|
|
hi, i have problem when i made application to change active directory user password using asp.net.
The application has been tested under C# console app..and it works,
but it gives access denied when i use asp.net
i have set some web config, it works only when i search the directory. but when i try to invoke IADsUser.SetPassword..again..access denied.
Anybody can help?
Thanks a lot
|
|
|
|
|
You have to give the proper permission to asp.net user , although its not safe. You can impersonate to another user which have sufficient permission for that purpose.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
How can I make my ListBox select whatever item my mouse is on when I RIGHT CLICK?
/\ |_ E X E GG
|
|
|
|
|
I never had any problems creating and finding event handlers using the C++ V6.0 ClassWizard but I don't find C# so easy to use in this respect. I have resorted to editing the code without the aid of a wizard on many occasions but I'm sure this can't be the best way - I imagine I'm missing something obvious . I have two specific questions:
How do you add an event handler to a Toolbar button? Double clicking doesn't do anything, if you right click there is no "add event handler" option, and the Control Events button does not appear on the Properties view. All these things work with Dialog buttons, why not with Toolbar buttons?
How do you create and locate handlers for UPDATE COMMAND UI messages? The V6.0 ClassWizard used to show these clearly but I can't find any reference to them on the C# Event Handler Wizard or the Properties view.
Any assistance would be greatly appreciated.
Best Regards
Cliff Hatch
|
|
|
|
|
Cliff, .NET is a bit different than MFC.
By doubleclicking a control in the visual designer you'll get an event handler created for the control's default event.
If you want to add any other eventhandler visually, then you'll have to use the Control Events button to show the events a selected control supplies (and which are marked designer-visible).
Nevertheless, adding event handlers manually is just as easy.
For example, adding a click event handler to a button in VS.NET can be achieved by typing
myButton.Click += and then TAB twice.
VS.NET finishes the statement and adds a new myButton_Click() event handler with the correct signature.
If the Control Events button doesn't appear for a certain control then this control doesn't have any public visible events.
Regarding the click on a ToolButton, this event is fired by the ToolBar containing the button.
And for menus, there's the Popup event that's fired just when a menu is about to appear, so you can use this event to enable/disable your menu items.
Regards,
mav
|
|
|
|
|
mav
Thankyou for your clear reply.
I now understand why the system behaves as it does, and I will try your method of adding handlers manually.
I'm still puzzled why the designers of .NET chose this route though. I wonder if they planned to discard MFC's wizard support for the creation of ToolButton and Update handlers, or if this was an unintended side effect of design rationalisation.
Best Regards
Cliff
|
|
|
|