|
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
|
|
|
|
|
Read Christian Gauss's articles about image manipulation and start using pointers to RGB memory positions instead of pixel[x,y].
This will make your code at least 20x faster.
Perl combines all the worst aspects of C and Lisp: a billion different sublanguages in one monolithic executable. It combines the power of C with the readability of PostScript. -- Jamie Zawinski
|
|
|
|
|
Since you don't have problem with memory (you allready load a 3300x2100 image!), try allocating table that holds the colors.
int colors[]=new int[16777216];
for(int i=0;i<16777216;i++) colors[i]=0; <br />
for(int y=0;y<img.Height;y++)<br />
{ <br />
for(int x=0;x<img.Width;x++)<br />
{<br />
test = true;<br />
colors[image.pixel[x,y]]++;<br />
}
- - - - - - - - - - - - - - - - - -
Memory leaks is the price we pay \0
01234567890123456789012345678901234
|
|
|
|
|
Since we now have a tight loop, a major amount
of execution goes into checking the loop command itself.
(checking x<img.width and="" brancing="" commands)
thus,="" we="" unroll="" the="" inner="" loop!
<code="">
for(int y=0;y<img.Height;y++)
{
// do chucks of 128 pixels at once
for(int x=0;x<img.Width-128;x++)
{
// 128 times
colors[image.pixel[x,y]]++;x++;
colors[image.pixel[x,y]]++;x++;
colors[image.pixel[x,y]]++;x++;
...
colors[image.pixel[x,y]]++;x++;
colors[image.pixel[x,y]]++;x++;
colors[image.pixel[x,y]]++;x++;
colors[image.pixel[x,y]]++;
}
// do the remaining pixels
for(;x<img.Width;x++)
{
colors[image.pixel[x,y]]++;
}
}
- - - - - - - - - - - - - - - - - -
Memory leaks is the price we pay \0
01234567890123456789012345678901234
|
|
|
|
|
Hello every one:
I have a question about a Game-Source-code.I have down some soure-code from codeproject,but I can not find the "Microsoft.directx.directdraw" dll,
I can use DxVbLib onely in my code.What shoud I do?
game
|
|
|
|
|
download and install DirectX
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
That will not suffice.
You will need the DirectX SDK (download the 2003 summer update), and installed Managed DIrectX (run the dxsetup.exe with /InstallManagedDX)
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Thank you:
Where can I get the "Managed DIrectX ".
game
|
|
|
|
|
I'm rather new to oleDatabases, but I got my table setup, and connected to it in my application using the oleDbDataAdapter. I have a DataSet which gets my rows from my .mdb table, and a combobox which fills from a column in this dataset. Here are my questions:
When I fill my dataset, my combobox automatically puts the top entry of the column into the textview. I want the text to remain blank, but the container to be filled. For some reason, comboBox1.Text = ""; doesn't do the trick, even if I call it directly after filling my dataset. How do I keep the text in my comboBox from selecting the first element in the container?
After I choose an item in the container, I would like to fill other text boxes with information from the same row in my table as the item in the combo box. How do I find and retrieve the row from my dataset?
Thanks a lot for the help. I hope I wasn't too vague on anything!
|
|
|
|
|
Try selecting the index -1 to not select the first item in the list.
comboBox1.SelectedIndex = -1;
You can also use the selected index to get an offset into the dataset to get the text, but I'm sure there is a better way.
|
|
|
|
|
http://blogs.msdn.com/ericgu/archive/2004/04/01/105644.aspx
|
|
|
|
|
Good one
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
hello, all.
I am trying to convert a struct from VB to c# in order to use an old DLL. Here is the definition in VB
Public Type CHost
Host As String * 60
Port As String * 5
Info As String * 120 'Inof returned from host
Timeout As String * 10
End Type
In the sample VB code:
Public Declare Function CConnect Lib "OLDDLL.DLL" (Host As CHost) As Integer
iError = CConnect(TheHost)
and then the CHost.Info was set by the remote host.
I converted it to(C#)
public struct CHost
{
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr,SizeConst=60)]
public string Host; //host name
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr,SizeConst=5)]
public string Port; //host port
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr,SizeConst=120)]
public string Info; //Info returned from remote host
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr,SizeConst=5)]
public string Timeout; //timeout
};
in my c# code.
[DllImport("OLDDLL",EntryPoint="CConnect")]
public static extern short CConnect(ref CHost Host);
short ierror = CConnect(ref theHost);
I can connect to the remote host but the theHost.Info was not set.
Could anybody let me know what I was doing wrong and what is the right way to do it?
|
|
|
|
|
Hi,
SQLHelpder class is given in "Data Access Application Block". This block sample code is availabe on
Microsoft MSDN. Why am I using this becuase of time saving. Useful overloads are available to do more in less time.
What I need in a form is the newly added IDs in a table. For example I wrote the following code
//This module will insert a new role in the tblRole table by calling the stored procedure uspRoleNew
SqlParameter[] arparam = new SqlParameter[9];
arparam[0] = new SqlParameter("@pRoleName",SqlDbType.VarChar, 50);
arparam[0].Value= mRoleName;
arparam[1] = new SqlParameter("@pRoleDesc", SqlDbType.VarChar,50);
arparam[1].Value= mRoleDescription;
.
.
. .
arparam[8] = new SqlParameter("@pRoleIDout", SqlDbType.Int);
arparam[8].Direction=ParameterDirection.Output;
SqlHelper.ExecuteNonQuery(clsGeneral.conStr, "uspRoleNew", arparam);
int _RoleID;
_RoleID = (int)arparam[8].Value;
In paramerter[8] i want the newly added ID. But SqlHelper is not returning any value.
Below is the alternative solution for the above problem
mSqlCommand.Connection= _Sqlconn;
mSqlCommand.CommandText="uspRoleNew";
mSqlCommand.CommandType=CommandType.StoredProcedure;
mSqlCommand.Parameters.Add("@pRoleName",SqlDbType.VarChar, 50);
mSqlCommand.Parameters[0].Value=mRoleName;
mSqlCommand.Parameters.Add("@pRoleDesc", SqlDbType.VarChar,50);
mSqlCommand.Parameters[1].Value= mRoleDescription;
mSqlCommand.Parameters.Add("@pRoleIDout", SqlDbType.Int);
mSqlCommand.Parameters["@pRoleIDout"].Direction= ParameterDirection.Output;
_Sqlconn.Open();
mSqlCommand.ExecuteNonQuery();
mRoleID = (int)mSqlCommand.Parameters["@pRoleIDout"].Value;
return mRoleID;
QUESTION ????? is Why sqlhelper not doing this. If u r aware of "Data Access Application Block" plz reply.
|
|
|
|
|
Hi,
Would anybody plz screw up this code.
SqlParameter[] arparam = new SqlParameter[3];
int _GroupID;
arparam[0] = new SqlParameter("@pGroupName",SqlDbType.VarChar, 50);
arparam[0].Value= mGroupName;
arparam[1] = new SqlParameter("@pGroupDesc", SqlDbType.VarChar,50);
arparam[1].Value= mGroupDescription;
arparam[2] = new SqlParameter("@pGroupIDout", SqlDbType.Int);
arparam[2].Direction=ParameterDirection.Output;
SqlConnection _Sqlconn = new SqlConnection(clsGeneral.conStr);
SqlCommand mSqlCommand = new SqlCommand();
mSqlCommand.Connection= _Sqlconn;
mSqlCommand.CommandText="uspGroupNew";
mSqlCommand.CommandType=CommandType.StoredProcedure;
mSqlCommand.Parameters.Add(arparam);
_Sqlconn.Open();
mSqlCommand.ExecuteNonQuery();
_GroupID = (int)mSqlCommand.Parameters["@pGroupIDout"].Value;
return _GroupID;
|
|
|
|
|
How would you like us to screw it up? You can start by changing random letters in variable and class names so that it will not compile. If you'd also like some runtime errors, change the name of a couple of stored procedures.
abidkayani1 wrote:
mSqlCommand.Parameters.Add(arparam);
There is no overload of SqlCommand.Parameters.Add that accepts an array of parameters as an argument.
Charlie
if(!curlies){ return; }
|
|
|
|
|
Hi,
I have a rather simple problem, yet I can't find an acceptable solution. It isn't much of a problem for users running my application at high resolution (1280x1024 for example), but it really is for 800x600 users (too bad they still exist!)
My application is a MDI and I use FormStartPosition.WindowsDefaultBounds for each child form in order for them to open underneath the previous one (cascade).
The problem is that if I open 3 or 4 windows, a scrollbar shows up on my MDI form and the user needs to scroll to see the new windows. It happens even when no windows are open (ie: 4 windows were opened, then closed, the user will need to scroll to see the next opened window because it is not positionned at the top of the screen like it should).
Is there an easy solution to this? Anyone else having this problem?
Thanks!
Carl
|
|
|
|