|
I'm relatively new to C# programming, but I am using it to develop an app on the .NET Compact Framework. This works fine, I can deploy it via USB to my device and so on. However, debugging it on the device is a bit of a pain because my app slows waaaay down when sending the debug status info back to my PC. If I take the exe and run it on my PC, it actually runs (mostly) fine and is pretty nifty. However, what I would love to do is run it in the debugger on my PC. I'm hoping it would get better performance for debugging that way. But I can't figure out if or how I can do that. The only options for debugging seem to require a device, either physically connected or through an emulator.
Anyway, I hope I'm not missing anything too obvious; I'm new to VS2005 as well as C#. I also would prefer not creating a regular C# project that happens to use the same source files.
Thanks!
|
|
|
|
|
I haven't ventured into vs 2005 yet but in vs 2003 there is an emulator for the smart apps, (PPC and Win CE). You are given the option to select either one in vs 2003.
Is this available in 2005? Not sure but it's worth mentioning.
Gav
|
|
|
|
|
Well, as the title says I want to save the current state of a Windows.Form object. I'm currently investigating on doing this with xml-serialization, but I don't know if this is the way to go. I don't need a complete essay about that (I would take that, too) but a hint that points me into the right direction. So, can someone help me out please?
Greetings
|
|
|
|
|
You won't be able to serialize a Form object. It's not serializable. What you can do is serialize the state of the application's data, and then reload that instead. XML serialization should work fine for that, but you might as well use the BinaryFormatter because it's faster and more compact.
If you also want to save the state of individual controls on a form, then you better hope that you're using some good 3rd party controls, like Infragistics. The MS inbox controls suck, and as such, don't provide runtime serialization APIs. But some 3rd party controls will save user configured settings for you, which is a nice feature for most apps.
Josh
|
|
|
|
|
Binary formatter will not work if the class changes. Meaning if you try to read a config file that was written before changes were made to the class. Xml serialization is a safer way to go.
Just create a simple class that hold the information you require and make it XML serializable. Use my article[^] if you need help with the serialization.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
If I got that right: Due to containing interfaces many classes can't be serialized. I want to save the state of my windows form. So I need to serialize elements of this form. These are Controls (Labels and UserControls). If the above applies, I see no way doing so, except serializing lets say the Text of a Label and then later deserialize the string, create a new Label and set the Text to the deserialized string, which is a really bad situation. Is there any better way?
|
|
|
|
|
Hi!
In C# v2.0 (Visual Studio 2005), there is a file, named Settings.settings in the properties folder in the Solution Explorer window, there you can assign some settings in different types and so you can assign a property like this:
Name: FormPosition
Type: System.Drawing.Point
Scope: User (Take care of this, it made me crazy to get this point: Application scope, is read-only and it will be the same as the value you gave to it at the beginning and you can not change it at runtime! But User scope is made to be assigned both at the beginning and at runtime. )
Value: 100, 100
and then at runtime, you can access this settings by using this code:
<br />
Point formPosition = global::YourNamespace.Properties.Settings.Default.FormPosition;
and even you can change the value at runtime this way:
<br />
Point formPosition = new Point(MyForm.Left, MyForm.Top);<br />
global::YourNamespace.Properties.Settings.Default.FormPosition = formPosition;
These values will be automatically stored in the registry of windows, and in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\RNG and in binary mode that is coded and not recoverable by users, but by your application.
Hope you could use it!
Sojaner!
|
|
|
|
|
Is there any way i can attach a database (oledb or whatever) to a DataGridView without filling an offline dataset first? So basically execute an SQL query against a database and display the results in a datagridview (without using .Fill(...) because it takes forever)
Thanks a lot,
Wouter
|
|
|
|
|
|
Thanks for your reply, I tried it but it seems the .DataBind() method has disappeared from the DataGrid (also from the DataGridView which I am using).
Following your hint using the DataReader i searched the web for further clues and i came around a page that fills a DataTable (by DataTable.Load(DataReader)) but that's not what I want (coz it takes ages to load)
Can you tell me how to do it without the unavailable DataBind() method?
Thanks,
Wouter
|
|
|
|
|
Wouter Van Ranst wrote: it seems the .DataBind() method has disappeared from the DataGrid
Is this ASP.NET?
|
|
|
|
|
just normal C#
|
|
|
|
|
So Winforms? There never has been a DataBind in Winforms that is in ASP.NET. DataBind provides the timing mechanism required in a Web application. In a process based application you are always bound after initialization.
|
|
|
|
|
thanks for clearing this up, so how do i attach the DataReader to the DataGridView, the code in the article doesn't work without the DataBind() method (nothing is displayed in the DataGridView)
|
|
|
|
|
I have not used a DataReader but the DataGridView.DataSource property is how you bind it to data.
|
|
|
|
|
Can some one help me out of understanding the delegate.
we are calling some method with delegate object.
program t1=new program()
delegateabc d1 = new delegateabc(t1.Testabc);
Here I am calling the method Testabc from class program.
I don't understand what is the benefit of calling through delagate
I can directly use t1.testabc not going through delagte.
can someone help me ou with the difference.
t
|
|
|
|
|
The code wouldn't call the function. For this you would have to add:
d1(probablySomeArguments);
In this simple scenario it doesn't make any sense. Let me try to construct a rather simple case where it could be useful:
Lets assume you have an array of numbers which you want to apply a function to each one:
public void Calculate(int[] numbers) {
for (int i = 0; i < numbers; i++)
numbers[i] = numbers[i] * 2;
}
This small snippet would double all numbers. But what if several callers want to do different things with those numbers? For this you *could* use a delegate:
public delegate int NumberCalculaterCallback(int number);
public void Calculate(int[] numbers, NumberCalculaterCallback callback) {
for (int i = 0; i < numbers; i++)
numbers[i] = callback(numbers[i]);
}
Now the caller could input any function it likes:
public class Caller {
private int Double(int number) {
return number * 2;
}
private int AddOne(int number) {
return number + 1;
}
private int Square(int number) {
return Math.Pow(number, 2);
}
public void Test() {
int[] numbers = new int[] { 1, 2, 3, 4, 5 };
Calculate(numbers, new NumberCalculaterCallback(Double));
Calculate(numbers, new NumberCalculaterCallback(AddOne));
Calculate(numbers, new NumberCalculaterCallback(Square));
}
}
Calculate now uses functions which it has absolute no clue about. This function could be anywhere, even in a different assembly. It just needs to know about the delegate definition and can then make any processing with the numbers the caller can think of.
|
|
|
|
|
Robert,
Thank you very much Now I understood filly.Thanks again for helping
in this concept
|
|
|
|
|
Hello All,
I am trying to read a row from a gridview and display the items in the row in to textboxes. I have my gridview set up and is working fine but I could't figure out how to take the selected row's items. Any help would be appriciated.
Thanks
|
|
|
|
|
<br />
GridViewRow gvr = gvYourGrid.Rows[X]<br />
tbYourTextBox = ((Label)gvr.FindControl("lblGridData")).Text;<br />
...continue for each cell or label to populate...<br />
<br />
tbYourTextBox = gvr.Cells[Y].Text;<br />
...continue for each cell or textbox you need to populate...<br />
X is the row you want the items from and Y is the cell;
|
|
|
|
|
Thank you so much for your reply. I understand what you mean and it is working perfect when I put in the row and column numbers but my problem is I don't know which row the user would select. The data is read form a database and I put a radio button beside all rows. I want the user select the row from the radio button and click on a button after that the information on that row would be shown in appropiate textboxes.
I am really stuck on that and I would really appriciate your help.
Thanks
|
|
|
|
|
Try this, you go through each row in the GridView looking for the one with the selected radio button and break out when you find it.
<br />
foreach (GridViewRow gvr in gvYourGridView.Rows)<br />
{<br />
if (((RadioButton)gvr.FindControl("rbYourRadioButton")).Checked)<br />
{<br />
<br />
break; <br />
}<br />
}<br />
-- modified at 17:55 Tuesday 27th June, 2006
EDIT: .Checked not .Selected
|
|
|
|
|
Great! Thank you so much, I really appriciate it.
Cheers
|
|
|
|
|
Let say I have 2 methods:
void BeginGroup();
void BeginGroup(string msg);
when I want to refer to them I write
/// <see cref="BeginGroup"/>
But this cause a compiler warning, where my declaration is ambiguous (between the 2 BeginGroup methods).
But what if I want to refer them both?
In much the same way as when you click on "Console.WriteLine" and you go to the page which lists all the possible polymorphic variations?
|
|
|
|
|
My main form can open multiple non-modal child windows (FormBorderStyle.FixedToolWindow, Owner set to the main form).
The main form has a MainMenuStrip with items that have shortcuts (e.g. Ctrl+F for "find", Ctrl+R for "replace"). But inside the "find" dialog, pressing Ctrl+R has no effect (well, it plays a beeping sound...).
How can I send the key presses to the MainMenuStrip? I want to forward only those key presses that are not handled by the child window.
|
|
|
|