|
You could copy the selected public properties (Text , LocationX , LocationY ) to a separate class and just serialize that. Your Load() method would then deserialize that class and return a new SubLabel with those properties set.
/ravi
|
|
|
|
|
Hello
I am developing a program for a community launcher/downloader
what i am here to ask is there libraries to download a repo through an autoconfig file for downloading and updating the mod
I want the user to be able to download from this repo ftp://62.210.148.145/public/.a3s/autoconfig and to download and put these ftp://62.210.148.145/public in a game directory
The autoconfig is in an .gz file
That's the file in a nutshell it doesn't have an extention
|
|
|
|
|
Help with which part? Sounds almost like you expect the library to do everything your app should do?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
A Point in the right direction
|
|
|
|
|
|
hello,
I have a click method for a button and try to iterate through all comboboxes on the form. When I try to access the control through the Controls collection the program jumps out of the method (in the line Control cc = this.Controls[i];). My code is below. Can anyone tell me what I'm doing wrong here?
public partial class NewTopicCtxCfgElemFrm : Form
{
private bool _freeConfig = false;
public NewTopicCtxCfgElemFrm()
{
InitializeComponent();
}
public void Initialize(Topic topic)
{
_freeConfig = business.TopicFactory.GetTopicTypeIsFreeConfigurable(topic.ID);
label1.Text = (_freeConfig) ? "Please select at least one of all." : "Please select all.";
List<TopicTypeObjType> list = business.TopicFactory.GetObjTypeForTopic(topic.ID);
int k = 0;
foreach (var item in list)
{
int y = GetNewLocationTop(k);
Label lbl = new Label();
lbl.Text = item.ObjTypeName;
lbl.Location = new Point(10, y);
lbl.Width = 200;
this.Controls.Add(lbl);
ComboBox cbx = new ComboBox();
cbx.Location = new Point(220, y);
cbx.Width = 200;
cbx.Tag = item;
this.Controls.Add(cbx);
List<Xerox.CDMG.XControls.XDataItem> objects = business.ObjLinkFactory.GetObjForObjType(item.ObjTypeID);
cbx.DataSource = objects;
cbx.SelectedIndex = -1;
k++;
}
Button btn = new Button();
btn.Text = "Save";
btn.Location = new Point(10, GetNewLocationTop(k));
btn.Width = 200;
this.Controls.Add(btn);
btn.Click += new EventHandler(btn_Click);
}
void btn_Click(object sender, EventArgs e)
{
try
{
bool checkRequiredObjTypesOk = !_freeConfig;
for (int i = 0; i < this.Controls.Count; i++)
{
Control cc = this.Controls[i];
ComboBox cb = cc as ComboBox;
if (cb != null)
{
if (!_freeConfig)
{
if (cb.SelectedIndex == -1) { checkRequiredObjTypesOk = false; }
}
else
{
if (cb.SelectedIndex > -1) { checkRequiredObjTypesOk = true; }
}
}
}
}
catch (Exception exc)
{
Logger.LogException(exc);
}
}
private int GetNewLocationTop(int k)
{
return k * 25 + label1.Top + label1.Height + 30;
}
}
|
|
|
|
|
Curious - what do you mean it jumps out? On which iteration of the loop - the first?
Regards,
Rob Philpott.
|
|
|
|
|
It differs, most of time on the first loop, sometimes in the second loop. I do not get any exception. I tried restarting visual studio, did not help. Also tried fornext(), but same result.
|
|
|
|
|
Well, I'm as confused as you. I can't see anything wrong with the code, and particularly not anything which would cause it to return from the function on that line.
The only very long shot I can think of is the pdbs are out of date of something and that's causing the debugger to lie to you.
Regards,
Rob Philpott.
|
|
|
|
|
pdbs??? could you elaborate please?
|
|
|
|
|
I really don't think that would be it, but, when you compile your exe it'll produce some .PDB files. These are the 'program database' files and are used by the debugger to map the execution point and variables etc. into the source code.
If it gets out of sync then you can see some very weird behaviour.
When execution leaves your button handler, does the application carry on?
Regards,
Rob Philpott.
|
|
|
|
|
How could i put the pdb file back in sync? I already tried a complete rebuild but that didn't help.
|
|
|
|
|
Do a "Clean Project" first, then recompile it.
|
|
|
|
|
You could try a complete rebuild of your project and then put a breakpoint at the beginning of the btn_Click method and run it through your debugger. You should also review what that method is trying to do. As it stands it seems to be setting checkRequiredObjTypesOk randomly to true or false , but never uses that value for any purpose.
|
|
|
|
|
That part was not finished yet.
|
|
|
|
|
OK. However I have just tested your code (modified to fit my sample) and it works fine using both for and foreach . You need to get to work with your debugger to see what is happening. I suspect some out of date code is getting linked in by mistake somewhere.
|
|
|
|
|
joost.versteegen wrote: the program jumps out of the method (in the lin No, it doesn't. It jumps out on the line after that, as your control is not a combo. Using "as" does not throw an exception, the variable is null and ignored.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
No, it does realy jump out of the line i specified. The debugger sometimes does not reach the "if (cb != null)" test!
|
|
|
|
|
Add in a Debug.WriteLine to show the names of the controls found. It will only loop the children, not any sub-children btw! The code will SKIP anything that is not directly on the form (IE, any combo that's on a panel).
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
took your advise and added a number of debug.writeln statements...the code did exactly what it was supposed to do...but the debugger keeps doing strange things. Thanks anyway!!
|
|
|
|
|
Did you deploy a version to the GAC?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
The debugger is sometimes a little buggy. Set a break point in one of the next lines to be hi. Generally, it will stop then there even if it uses to leave the method to nowhere.
|
|
|
|
|
I tried lot of coding but not yet to get the answer. so could you help me. please send me source code and c# code for that.
|
|
|
|
|
It doesn't quite work like that.
We do not do your work for you.
If you want someone to write your code, you have to pay - I suggest you go to VWorker.com and ask there.
But be aware: you get what you pay for. Pay peanuts, get monkeys
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Google will find you many samples.
|
|
|
|