|
Any ideas on how to go about serializing a winform using C#.
|
|
|
|
|
Easy enough. Forms aren't serializable...
RageInTheMachine9532
|
|
|
|
|
As said, the Form class isn't serializable. But it should be enough to serialize step by step the most important properties like Size and Font.
|
|
|
|
|
...or extend Form and attribute the class with [Serializable] . By default, all private and protected fields are serialized if they themselves are serializable. If you want more control on how your class is serialized, implement the ISerializable interface. More information about the SerializableAttribute class and ISerializable interface can be found in the .NET Framework SDK documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi
i have a problem accessin the arraylist i made in a form by another form as i had to make static array and when i put data in it in for loop it just saves the last data the loop put what can i do?
thanx
|
|
|
|
|
A static array exists only once. Anything you do to it will reflect elsewhere. Make it non static so that each instance has it's own array.
If you are using a form, try calling the array from a non static method. You are probably trying to read it from main.
Cata
|
|
|
|
|
thanx
but i don't need that each instance have its own array as i need the data from the array that i put in the 1rst form in the second to do changes in it then i need the changed array in the 3rd form
|
|
|
|
|
Ok, you could always use the array.clone() method, to copy it into a local array, and then apply the changes there. THEN forward the modified array.
This will keep the origional array unchanged, but enable you to manipulate a modified version.
|
|
|
|
|
You might want to post some code samples of your array and what your doing to modify it.
RageInTheMachine9532
|
|
|
|
|
((Offices)(OfficesNames[i])).OfficeAtt= new ArrayList(AllNodes);
Offices ->class
OfficesNames->array of object of offices
officeAtt->arraylist have object of another class called attributes
this line of code to intialize the arraylist of attributes of each office
for(int i=0;i
|
|
|
|
|
When you enumerate a collection or list (anything that implements IEnumerable , it is documented behavior to throw an exception. This is to ensure that changes to the list or collection aren't skipped when looping. You can either clone the list or collection or use an iterative loop (for , as opposed to foreach ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hello dave,
remeber me?? today i am asking about keystrokes in every applications...i want to trace keystrokes and specify in which application were they typed..wait ur reply...give me hint in which way to search..thanks in advance
|
|
|
|
|
|
You talking about capturing keystroke and logging what is typed and in which application they are typed?
Since your requirements include loggin WHICH application recieves the keyboard message, you've added a new layer of complexity to your app. You can't simply use just the keyboard hooks function anymore since you will never receive any notification of where the message is going. To get that, you also have to use the CBTProc callback function (or hook) to keep track of the window that's currently activated. You have to get the name of the window using the window handle that's passed in during certain events that get sent through your CBTProc procedure.
RageInTheMachine9532
|
|
|
|
|
I m so and feeling bkz i m
CommandBarComboBox
i m making Add ins for outlook .I have added a ControlEdit button in
CommandBar collection using the following code...
oEdit = (JOffice.CommandBarComboBox)
oCommandBar.Controls.Add(JOffice.MsoControlType.msoControlEdit,oMissing,oM
issing,oMissing,oMissing);
oEdit.BeginGroup = true;
oEdit.Text = "Search";
oEdit.Tag="URL";
oEdit.Caption="Search Word";
now the problem is when i m fatching the value from edit box ,it is not
returning me the value.I m not able to get the value which i have
written inside the edit box .the code i have written for this is following
private void oButton1_Click(JOffice.CommandBarButton Ctrl, ref bool
Cancel)
{
try
{
CommandBarComboBox tempCom;
tempCom =
(CommandBarComboBox)oCommandBar.FindControl(JOffice.MsoControlType.msoCont
rolEdit, "oEdit", "URL", false, false);
Sval=tempCom.Text;
System.Windows.Forms.MessageBox.Show(Sval); // here no value
Test1.JOutLookLib.SearchURL("http://www.google.co.in/search?q="
+Sval+"+&ie=UTF-8&oe=UTF-8&hl=en&btnG=Google+Search&meta=");
}
->NOTE : JOffice is an Alias for Namespace which I have included in My Code
when i write any value inside the edit box and click the button the new
value is auto clears and again the old value appears .I don't know how i
can solve it .I need the new values and it is returning old values .,...
mean it is not refreshing .
Please solve it it is very .....
Thanks for Help and ur time
|
|
|
|
|
I've just finish my project so I want to create a setup project but i do not known how to include the .NET Framework, Crystal Report into setup project.
Please help me.
Thanks
Mr Duc Linh Nguyen
|
|
|
|
|
You can't include the .NET Framework - it must be bootstrapped. Read Redistributing the .NET Framework[^] in the .NET Framework SDK for more information, including how to get example source and use that to bootstrap (i.e., run installations required for your installation PRIOR to running your installation).
To install the Crystal Reports managed runtime (includes unmanaged code as well), read Deploying Crystal Reports in .NET Applications[^]. There are four merge modules (.msm) that you include with your Windows Installer setup project. These are merged (hence the name) with the installer package when built. The regwiz MSM requires a license key that you can get for free by registering the Crystal Reports designer when you use it for the first time. This would've been emailed to you. For Windows Forms client applications, you have royalty-free redistribution rights. Read Incorporating Reports into Applications[^] for more information about licensing and different scenarios.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
i do not know how to catch error in data grid cell. this is the code i writed:
private void ColumnChangingHandler(object sender,DataColumnChangeEventArgs args)<br />
{<br />
switch(args.Column.ColumnName)<br />
{<br />
case "accID":<br />
{<br />
DataGridCell oldCell= new DataGridCell();<br />
string values=args.ProposedValue.ToString();<br />
if(!this.IsNumber(values))<br />
{<br />
MessageBox.Show("value must be number");<br />
}<br />
else<br />
if(!IsLengh(values))<br />
{<br />
MessageBox.Show("It must be 4 characters");<br />
}<br />
break;<br />
}<br />
..............................<br />
after catch error i want to return the focus on error cell.
Please help me as possible as you can.
Thanks.
Mr Duc Linh Nguyen
|
|
|
|
|
I am not sure what you need to do, but I think this can help you..
In the constructor of the form (for example), you add something like this :
DataGridTextBoxColumn _datagridtextBox = (DataGridTextBoxColumn)YourDataGrid.TableStyles[0].GridColumnStyles[X];<br />
_datagridtextBox.TextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(Execute_This);
where X is the index of the column that is supposed to have only numbers of 4 characters..
You will also need to write something like this :
private void Execute_This(object sender, System.Windows.Forms.KeyPressEventArgs e)<br />
{<br />
<br />
TextBox tBox = (textBox) sender;<br />
<br />
}
|
|
|
|
|
Hi, Guys
I need to get data type for the streams that I read into the memroy.
Assumption is that we don't know anything about file.(we do know deliminator, which in this case is '#')
for example input files is as follows
name#money#loanNumber
Joe#10000#L01
Amy#2000#L05
Tom#12000#L11
As you see, column name and loadNumber is type of string, and money is integer.
However, how do I decide in my c# program? should I make compare set of {'0', ..., '9'} and compare one by one for all the characters? Or is there any other way to decide these data type.
Thanks guys!
|
|
|
|
|
- Read one line
- Parse that line for '#'
- Split the line into its substrings
- Analyze any substring, using String.IndexOfAny( "ABCDEFG..." )
- If index found, it is a string; else, it is an integer
|
|
|
|
|
Thank you!!
you saved me!
|
|
|
|
|
i have an image of size 3300 * 2100. I am looping through the pixels and counting the number of colors in image and total number of pixels for each color. This code takes about 9 Minutes to Run on PIV 1.6GHz with 512 MB RAM. I want to significantly reduce this time. I am using Hashtable whose key is color and value is number of pixels of that color. Any suggestion will be highly appreciated. Here is the code.
In this code image is the object of Bmp class which i have made to read and write Bitmap faster using unsafe code.
<br />
ArrayList GetAllObjects(); <br />
{ bool test;<br />
int count=0;<br />
ArrayList list=new ArrayList();<br />
ArrayList final=new ArrayList();<br />
Hashtable ObjHash=new Hashtable();<br />
<br />
for(int y=0;y<image.Height;y++)<br />
{ <br />
for(int x=0;x<image.Width;x++)<br />
{<br />
test = true;<br />
<br />
if( ObjHash.ContainsKey(image.pixel[x,y].GetColor()) )<br />
{<br />
int val= (int)ObjHash[image.pixel[x,y].GetColor()];<br />
ObjHash[image.pixel[x,y].GetColor()]=++val;<br />
test=false;<br />
}<br />
<br />
if(test)<br />
{<br />
ObjHash.Add(image.pixel[x,y].GetColor(),1);<br />
list.Add(image.pixel[x,y].GetColor());<br />
count++;<br />
}
<br />
}
}
<br />
for(int i=0;i<list.Count;i++)<br />
{<br />
if( (int)ObjHash[(Pixel)list[i]] > 1000)<br />
final.Add((Pixel)list[i]);<br />
}<br />
<br />
return final;<br />
}<br />
Any suggestions??
Thanks!
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
Why not use a local color variable, rather than looking the color up for each iteration?
<br />
Color currColor = image.pixel[x,y].GetColor();<br />
<br />
if( ObjHash.ContainsKey(currColor) )<br />
{<br />
int val= (int)ObjHash[currColor];<br />
ObjHash[currColor]=++val;<br />
test=false;<br />
}<br />
else
{<br />
ObjHash.Add(currColor),1);<br />
list.Add(currColor);<br />
count++;<br />
}
<br />
On top of that, you could try managing your arraylist and hashtable size. As enlarging a hashtable or Arraylist is a large overhead, and you are doing 6,930,000 loops, it might be worth setting the size of your arraylist and hash table to AL.Size + 1000; when it's full. Then trim it after the loops.
Why are you swapping the arraylists at the end? This could take a while if you have a few thousand entries. Why not trim the origional one, and return that?
Cata
|
|
|
|