|
Sorry, can give explain me more detail than this?
Chuon Visoth
Angkor Wat - Cambodia
asp.net - c sharp beginner
|
|
|
|
|
It's not possible to explain it in more detail, because it's just too simple... Maybe my explanation was not clear enough, I'll try once more.
You asked how to refresh a combobox after a child form has closed.
The answer is simple - the code that refreshes the combobox should be right behind the form.ShowDialog() line. It will be executed as soon as the child form is closed, and that's what you want.
|
|
|
|
|
private void lkl_additem_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) //form1
{
//Open form2 from form1
form2 frmitem = new form2();
frmitem.ShowDialog();
this.cbo_itemname.Refresh(); // This is a combobox in form1 which I wanna update when form2 closes.
}
Is the code like this??? However, it doesn't work.
Chuon Visoth
Angkor Wat - Cambodia
asp.net - c sharp beginner
|
|
|
|
|
Hi,
Actually he wants you to place the code that refreshes the combobox just before the following line in ur code..
frmitem.ShowDialog();
Hope u understand....
Regards,
Tash
|
|
|
|
|
Thnx a ton. Ur solution is the best
|
|
|
|
|
What is the equivalent window style for FormBorderStyle.Fixed3D, FormBorderStyle.FixedSingle, FormBorderStyle.FixedDialog, FormBorderStyle.SizableToolWindow and FormBorderStyle.FixedToolWindow? The only one I know is WS_THICKFRAME for FormBorderStyle.Sizable.
|
|
|
|
|
So I'm trying to display an icon in a PictureBox control while preserving the alpha of the icon image. Loading the icon and applying it to the control looks something like this:
Icon icon = new Icon("thisIsTheIcon.ico");
pboAppIcon.BackgroundImage = icon.ToBitmap();
This works fine except that all transparent areas of the icon are show as black. I tried to get around this using the Bitmap class' .MakeTransparent method, but the result looks terrible, since the icon uses varying alpha translucency (near-black artifacts remain).
Normally I'd just let this go as a .Net eccentricity, except that I've seen another application achieve exactly what I'm after using identical code and icons. I'm wondering if there's a Form style or a flag somewhere that needs to be changed.
Does anyone have any suggestions?
|
|
|
|
|
You have to load the file as Bitmap, not Icon.
Bitmap bmp = (Bitmap)Image.FromFile("thisIsTheIcon.ico");
pboAppIcon.BackgroundImage = bmp;
|
|
|
|
|
I have an array of bytes. I need to remove the first 16 bytes of the array, then append another byte array onto it. What do you suggest is the best way to do this?
|
|
|
|
|
Hi,
for small arrays, just do it; i.e. allocate a new array of correct length, and copy the data you want in it (see Array.Copy).
for large arrays (hundreds of MB), don't do it; make sure you don't need it, i.e. either make your consumer smart enough to skip some, and combine two arrays, or teach your producer(s) to first disclose lengths so you can allocate the final array at once, then let the producer(s) fill their allotted space.
FYI: most .NET methods that take an array also have an overload that takes (array, startindex, length) in an attempt to alleviate such problems.
|
|
|
|
|
I addition to Luc's advice, have a look at the System.Buffer[^] class, specifically it's BlockCopy[^] method.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I rarely use Arrays in a situation like this. I prefer using the generic List[^] class. Using a list for your application would look like this:
Using System.Collections.Generic;
[...].
List<Byte>myList = new List<Byte>();
myList.AddRange(someByteArray);
myList.RemoveRange(0,16);
myList.AddRange(someOtherByteArray);
Byte[] retVal = myList.ToArray();
return retVal;
|
|
|
|
|
If you really must use an array, then the others have already given you perfectly reasonable options. However, you could also create a new data structure that is like a list but that you can remove items from both sides without a speed penalty.
A list works by internally storing an array and removing/adding elements near the end of the array as needed. If you remove items from the beginning of a list, all the rest of the items will have to be shifted to the beginning to get rid of those empty elements. However, your class (DoubleSidedList?) could just keep the values near the center of the array. That way, you could trim or add to either side without worrying about speed problems when expanding or contracting either side of the collection.
Naturally, this would incur a small performance penalty due to wrapping an array in a collection type.
|
|
|
|
|
If the size is very large and performance is very important, I suggest you create a new data structure:
class ExArray{
byte[] data;
int start;
int end;
public this[int i]
{
get { return data[(start + i) % data.Length]; }
set { data[(start + i) % data.Length = value; }
}
public Length { get { return end - start >= 0 ? end - start : end - start + data.Length; }}
public void Shift(...){...}
public void Slice(...){...}
}
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 8:58am.
|
|
|
|
|
I need to add the ability to initiate a Skype call in a C# WinForms app. I have Googled this alot and I see lot's of examples to other things, but no example to call someone.
Anyone know how to do this?
Everything makes sense in someone's mind
|
|
|
|
|
|
Hi Allow,
Can anybody let me know how the first constructor works in below code. Whats the use in writing it.
public class c
{
public c(string a) : this()
{;};
public c() {;}
}
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
indian143 wrote: Whats the use in writing it.
From what you have posted none whatsoever, there is also a syntax error on the line
{;};
so it does not even compile.
|
|
|
|
|
Ok. If I removed ; from the {;}; as below whats the o/p and why?
public class c
{
public c(string a) : this()
{;}
public c() {;}
}
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
I;m not sure where you got that code from but it's called Contructor Chaining.
When overloading constructors, code can be greatly simplified by one constructor calling another that has the code in it for all or many constructors.
To this end, it is more normal for the constructor(s) with more parameters to contain the code and to be called by the 'lesser' constructor(s)... i.e.
public class Class
{
private string name;
public Class(string name)
{
this.name = name;
}
public Class()
: this(string.Empty)
{ }
public string Name
{
get { return name; }
}
}
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Oh. Great thanks Dave. Thanks a Lot.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
Hey,
I'm working on a C# project where I'm using a boolean flag to determine if I need to recompute a value, but when I get to evaluating the boolean flag (in an if statement), if it's false, it will just flip the value of the flag to true, and enter the if block anyway. For clarification:
if (currAreaValid)
{
return area;
}
that's it. That's all the code. currAreaValid is false when it reaches the if statement, then just turns to true, and my method returns area. Now, it gets a little nuttier. If I hardcode "false" in the if statement, instead of currAreaValid, the value of currAreaValid still flips after the if block. I don't know why. I've tried cleaning and rebuilding the solution, but that didn't help. Has anyone seen a problem like this before? The only place I set the value of currAreaValid to true is in the same method that this if block is in, but at the very end of the method, which is 2 lines after the if block.
I have no idea what's going on. Can anyone help?
|
|
|
|
|
Hi,
some of the code you did not show must be relevant to this.
are you using static anywhere?
are you using timers or Threads or asynchronous handlers that call the method that contains your snippet?
|
|
|
|
|
Yeah, I know that some of the other code would be relevant, but I didn't know what to post and didn't want to post the whole project, obviously, lol.
Anyway, I am using no timers or threads (I don't think?). I'm trying out delegates for the first time in C# since I thought a functional approach would be good for some aspects of my data structure (Map and Fold functions)...for that I use static functions as delegates...but these don't call the method (which is a property, but I don't think that should matter). The method/property (called PolygonArea) makes a call to a Fold method which takes in a static delegate (area2Helper), and that static delegate does make a call to a static method in a static class (static method Area in static class Globals), but the property is only being called by my main method (which is static, but it's just my main method).
Do you think that it's something with one of my uses of static that shouldn't be static? If you need more information, let me know, and if you want me to post any code, let me know. Thanks!
~Andy
|
|
|
|
|
Aha.
1.
My debugging rule #1 is: when something goes wrong, it either is your fault (very likely for a novice, quite likely for an experienced programmer) or it is not (rather unlikely, as most bugs get discovered and reported by the thousands of other users and some/most of them get fixed before you would encounter them).
Now if it's your fault, then it could well be one or several of your assumptions is wrong. So don't assume a thing, check all of it. Step through your code and watch; or add logging statements and watch.
2.
having more than one thread (or a timer, or an asynchronous handler) may result in the same method being executed more than once at the same time; when that method operates on the same object, or on static data, it would confuse the person debugging it.
3.
Yes, in order to pinpoint anything, I would need to see more code. Maybe this:
- the declaration of the relevant variables, within their scope (method? class?)
- the method and class the snippet is part of.
- all the callers to the method behaving badly.
4.
How can your code be to large to publish? Did you type tens or hundreds of lines, and then discovered nothing really worked? Then start developing in an incremental way: create something small, observe it, and change it until what you have works the way it should; only then start expanding it a little. Repeat this process until done. Do not a big thing and then observe its failure, since by then you will have several bugs and their combination will significantly increase your debugging problems.
|
|
|
|