|
Could you explain much more your problem ?
|
|
|
|
|
Thank you for your response LongHC. It is like that
1> I opened a new console application in microsoft studio.net for C#.
2> Say , I modified it to write "HelloWorld" program.
3> I build it and run it. everything is fine till now.
4> I close it.
5> I come back tomorrow ro sometime after and feel like i want to make some changes in the code of HelloWorld.cs
6> so I open the file HelloWorld.cs, but i can't see the build option on the toolbar at all. I can't build it if i want to and hence i can't do any modification to it. So, now i have to open a new console apllication. Defnitely that will have the Build option on the toolbar but thing is that I have to do everythign once more or i have copy my previous program to the new file.
I know I am doing somethign really silly, but can't really figure out. Do i need to make somechanges in the option setting?
Regards,
Amit
|
|
|
|
|
Any file that is openj in the vs cann't be build ,cuz it's not in solution file or project file,if you want to be able to compile it ,don't open just the file,but open the .csproj file or the .sln file and you will be able to do any thing.
|
|
|
|
|
Thanks very much from a novice..
Take Care
|
|
|
|
|
amitmohanty wrote:
Thanks very much from a novice..
You ?
amitmohanty wrote:
Take Care
?
|
|
|
|
|
I am novice
|
|
|
|
|
i want to create a Crystal report, all the records are stored in DATASET how can create a report from dataset
i tried this code but it's not working
Report1 is blank
***************************************
Report1 rpt = new Report1();
rpt.SetDataSource(dsrefresh);
crystalReportViewer1.ReportSource = rpt;
***************************************
this code will UNION all DBF files from temporary folder, to dataset.
this part is ok
while (i < countdays)
{
DirectoryInfo Folders = new DirectoryInfo(@ALOHA_PATH+"\\"+datefolders+"");
if (Folders.Exists)
{
string ITMConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + ";Extended Properties=dBase IV";
OleDbConnection ITMConnection = new OleDbConnection(ITMConnString);
string ITMSelectQuery = "Select * from "+ALOHA_PATH+"\\GNDITEM.DBF UNION ALL Select * from "+ALOHA_PATH+"\\"+datefolders.ToString()+"\\GNDITEM.DBF" ;
//MessageBox.Show(ITMSelectQuery);
OleDbDataAdapter da= new OleDbDataAdapter(ITMSelectQuery ,ITMConnection);
da.Fill (dsrefresh,"GNDITEM");
dv = new DataView(dsrefresh.Tables["GNDITEM"]);
dataGrid1.DataSource = dv;
ITMConnection.Close();
}
i +=1;
// frmwait.Close();
// this.Show();
}
dv = new DataView(dsrefresh.Tables["GNDITEM"]);
dataGrid1.DataSource = dv;
|
|
|
|
|
I am trying to make a webservice that return a image to ppc. I have tried to return it as a bitmap but it give this following error "System.Drawing.Bitmap cannot be serialized because it does not have a default public constructor" so I changed from bitmap to base64 string, this works, however when I tried to convert base64 string back to bitmap(on ppc) I got the same error again.. Do anyone know exactly what I should do?
|
|
|
|
|
Make sure to extract the bytes of the image to transfer. (And base64 that array)
public Image GetImageFromBytes( byte[] bytes )
{
MemoryStream stream = new MemoryStream(bytes);
Image image = Image.FromStream( stream );
return image;
}
public byte[] GetImageBytes(Bitmap bitmap)
{
MemoryStream stream = new System.IO.MemoryStream();
bitmap.Save( stream, System.Drawing.Imaging.ImageFormat.Jpeg );
stream.Position = 0L;
System.IO.BinaryReader reader = new System.IO.BinaryReader(stream);
byte[] bytes = reader.ReadBytes( (int)stream.Length );
stream.Close();
return bytes;
}
|
|
|
|
|
public Image getObjectPicture(string objectID)
{
OdbcConnection connection= new OdbcConnection(@"Driver={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=ic;UID=;PASSWORD=;");
OdbcCommand cmm = new OdbcCommand("SELECT Picture FROM Object WHERE ObjectID='"+objectID+"'", connection);
connection.Open();
OdbcDataReader reader = cmm.ExecuteReader();
string filename= @"c:\default.bmp"; //default pic
while(reader.Read())
{
filename = reader[0].ToString();
}
Bitmap bitmap = new Bitmap(filename);
MemoryStream stream1 = new System.IO.MemoryStream();
bitmap.Save( stream1, System.Drawing.Imaging.ImageFormat.Bmp );
stream1.Position = 0L;
BinaryReader br = new BinaryReader(stream1);
byte[] bytes = br.ReadBytes( (int)stream1.Length );
stream1.Close();
MemoryStream stream2 = new MemoryStream(bytes);
Image image = Image.FromStream( stream2 );
return image;
}
I combined the given code and did this, and I got this error message "System.Drawing.Imaging.ImageFormat cannot be serialized because it does not have a default public constructor.", I put this coding on the webservice though.. that exactly should I do, I am rather confuse now
|
|
|
|
|
Hi,
I have many questions about checkbox :
1/I would like to create dynamicaly 8 checkbox into a form.
The name of each checkbox begin with "CHECKBOX_CAM_".
So :
CHECKBOX_CAM_1
CHECKBOX_CAM_2
CHECKBOX_CAM_3
...
CHECKBOX_CAM_8
2/ I would like to set/get some properties like text,position, tag,... with a SQL Database.
3/ I would like to retrieve the state of the group to a byte at any moment. when the user un/select one or more checkbox.
Best Regards
youssef
|
|
|
|
|
////////////////////////////////////////
CheckBox[] CheckBox1 = new CheckBox[8];
for (int i = 0; i < CheckBox1.Length; i++)
{
CheckBox[i].ID = "CHECKBOX_CAM_" + i.ToString().Trim();
}
///////////////////////////////////////
...
public string GetCheckBoxText(int x)
{
return CheckBox[x].Text;
}
public bool[] GetChecked()
{
bool[] a = new bool[8]
for ()
{
...
}
return a;
}
ASP.NET C# VB VC & SQL Windows APP ...
|
|
|
|
|
Hello
I have a school-project in C#. I'm using Visual C# 2005 Express Beta Edition.
In my Project I have about 7 Forms that all have the same Menu at the top. So I thought about putting the Code of the Menu in an extra DLL and include that DLL in my Forms.
Right now I am at the point that I can see the Menu wenn I start the Project. My question now is how can I connect the Event.Click of my Menu Items with The Forms that should be started wenn I Click the Item. Every Form that needs the Menu should also be reachable over the Menu.
I thought that I could take the Forms in an Arraylist but it make problems
Here is the Code of the DLL. The First part doesn't make any problems. But the second part make errors when i start the Project. It tells me something like i should be shure not to make an endless loop.
I call the DLL-constructor in the Forms with
Arraylist forms = new Arraylist(10);
Form1 for1 = new Form1();
.
.
.
forms.Insert(0, for1);
.
.
.
menue m = new menue(this, forms);
<br />
<br />
#region Using directives<br />
<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
<br />
#endregion<br />
<br />
namespace menuelib<br />
{<br />
public class menue : MenuStrip<br />
{<br />
Form neu = new Form();<br />
ArrayList forms = new ArrayList(10);<br />
Form formular = null;<br />
private ToolStripMenuItem dVDToolStripMenuItem;<br />
private ToolStripMenuItem erstellenToolStripMenuItem;<br />
private ToolStripMenuItem bearbeitenlöschenToolStripMenuItem;<br />
private ToolStripMenuItem personToolStripMenuItem;<br />
private ToolStripMenuItem erstellenToolStripMenuItem1;<br />
private ToolStripMenuItem bearbeitenlöschenToolStripMenuItem1;<br />
private ToolStripMenuItem dVDListeToolStripMenuItem;<br />
private ToolStripMenuItem verleihToolStripMenuItem;<br />
private ToolStripMenuItem ausleihenToolStripMenuItem;<br />
private ToolStripMenuItem geliehenToolStripMenuItem;<br />
<br />
<br />
public menue()<br />
{ }<br />
<br />
public menue(Form form, ArrayList formen) : this()<br />
{<br />
formular = form;<br />
forms = formen;<br />
dVDToolStripMenuItem = new ToolStripMenuItem();<br />
erstellenToolStripMenuItem = new ToolStripMenuItem();<br />
bearbeitenlöschenToolStripMenuItem = new ToolStripMenuItem();<br />
personToolStripMenuItem = new ToolStripMenuItem();<br />
erstellenToolStripMenuItem1 = new ToolStripMenuItem();<br />
bearbeitenlöschenToolStripMenuItem1 = new ToolStripMenuItem();<br />
dVDListeToolStripMenuItem = new ToolStripMenuItem();<br />
verleihToolStripMenuItem = new ToolStripMenuItem();<br />
ausleihenToolStripMenuItem = new ToolStripMenuItem();<br />
geliehenToolStripMenuItem = new ToolStripMenuItem();<br />
this.SuspendLayout();<br />
<br />
<br />
<br />
this.Items.AddRange(new ToolStripItem[] {<br />
this.dVDToolStripMenuItem,<br />
this.personToolStripMenuItem,<br />
this.dVDListeToolStripMenuItem,<br />
this.verleihToolStripMenuItem});<br />
Location = new Point(0, 0);<br />
Name = "menuStrip1";<br />
Padding = new Padding(6, 2, 0, 2);<br />
Raft = RaftingSides.Top;<br />
TabIndex = 0;<br />
Text = "menuStrip1";<br />
<br />
formular.Controls.Add(this);<br />
<br />
<br />
dVDToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] {<br />
erstellenToolStripMenuItem,<br />
bearbeitenlöschenToolStripMenuItem});<br />
dVDToolStripMenuItem.Name = "dVDToolStripMenuItem";<br />
dVDToolStripMenuItem.SettingsKey = "Form1.dVDToolStripMenuItem";<br />
dVDToolStripMenuItem.Text = "DVD";<br />
<br />
erstellenToolStripMenuItem.Name = "erstellenToolStripMenuItem";<br />
erstellenToolStripMenuItem.SettingsKey = "Form1.erstellenToolStripMenuItem";<br />
erstellenToolStripMenuItem.Click += new System.EventHandler(this.erstellenToolStripMenuItem_Click);<br />
erstellenToolStripMenuItem.Text = "erstellen";<br />
<br />
bearbeitenlöschenToolStripMenuItem.Name = "bearbeitenlöschenToolStripMenuItem";<br />
bearbeitenlöschenToolStripMenuItem.SettingsKey = "Form1.bearbeitenlöschenToolStripMenuItem";<br />
bearbeitenlöschenToolStripMenuItem.Click += new System.EventHandler(this.bearbeitenlöschenToolStripMenuItem_Click);<br />
bearbeitenlöschenToolStripMenuItem.Text = "bearbeiten/ löschen";<br />
<br />
personToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] {<br />
erstellenToolStripMenuItem1,<br />
bearbeitenlöschenToolStripMenuItem1});<br />
personToolStripMenuItem.Name = "personToolStripMenuItem";<br />
personToolStripMenuItem.SettingsKey = "Form1.personToolStripMenuItem";<br />
personToolStripMenuItem.Text = "Person";<br />
<br />
erstellenToolStripMenuItem1.Name = "erstellenToolStripMenuItem1";<br />
erstellenToolStripMenuItem1.SettingsKey = "Form1.erstellenToolStripMenuItem1";<br />
erstellenToolStripMenuItem1.Click += new System.EventHandler(this.erstellenToolStripMenuItem1_Click);<br />
erstellenToolStripMenuItem1.Text = "erstellen";<br />
<br />
bearbeitenlöschenToolStripMenuItem1.Name = "bearbeitenlöschenToolStripMenuItem1";<br />
bearbeitenlöschenToolStripMenuItem1.SettingsKey = "Form1.bearbeitenlöschenToolStripMenuItem1";<br />
bearbeitenlöschenToolStripMenuItem.Click += new System.EventHandler(this.bearbeitenlöschenToolStripMenuItem1_Click);<br />
bearbeitenlöschenToolStripMenuItem1.Text = "bearbeiten/ löschen";<br />
<br />
dVDListeToolStripMenuItem.Name = "dVDListeToolStripMenuItem";<br />
dVDListeToolStripMenuItem.SettingsKey = "Form1.dVDListeToolStripMenuItem";<br />
dVDListeToolStripMenuItem.Text = "DVD-Liste";<br />
dVDListeToolStripMenuItem.Click += new System.EventHandler(this.dVDListeToolStripMenuItem_Click);<br />
<br />
verleihToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] {<br />
ausleihenToolStripMenuItem,<br />
geliehenToolStripMenuItem});<br />
verleihToolStripMenuItem.Name = "verleihToolStripMenuItem";<br />
verleihToolStripMenuItem.SettingsKey = "Form1.verleihToolStripMenuItem";<br />
verleihToolStripMenuItem.Text = "Verleih";<br />
<br />
ausleihenToolStripMenuItem.Name = "ausleihenToolStripMenuItem";<br />
ausleihenToolStripMenuItem.SettingsKey = "Form1.ausleihenToolStripMenuItem";<br />
ausleihenToolStripMenuItem.Text = "ausleihen";<br />
ausleihenToolStripMenuItem.Click += new System.EventHandler(this.ausleihenToolStripMenuItem_Click);<br />
<br />
geliehenToolStripMenuItem.Name = "geliehenToolStripMenuItem";<br />
geliehenToolStripMenuItem.SettingsKey = "Form1.geliehenToolStripMenuItem";<br />
geliehenToolStripMenuItem.Text = "geliehen";<br />
geliehenToolStripMenuItem.Click += new System.EventHandler(this.geliehenToolStripMenuItem_Click);<br />
<br />
this.ResumeLayout(false);<br />
}<br />
<br />
<br />
<br />
private void erstellenToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
this.Visible = false;<br />
neu = (Form)forms[0];<br />
neu.ShowDialog();<br />
}<br />
private void bearbeitenlöschenToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
this.Visible = false;<br />
neu = (Form)forms[1];<br />
neu.ShowDialog();<br />
}<br />
private void erstellenToolStripMenuItem1_Click(object sender, EventArgs e)<br />
{<br />
this.Visible = false;<br />
neu = (Form)forms[2];<br />
neu.ShowDialog();<br />
}<br />
private void bearbeitenlöschenToolStripMenuItem1_Click(object sender, EventArgs e)<br />
{<br />
this.Visible = false;<br />
neu = (Form)forms[3];<br />
neu.ShowDialog();<br />
}<br />
private void dVDListeToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
this.Visible = false;<br />
neu = (Form)forms[4];<br />
neu.ShowDialog();<br />
}<br />
private void ausleihenToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
this.Visible = false;<br />
neu = (Form)forms[5];<br />
neu.ShowDialog();<br />
}<br />
private void geliehenToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
this.Visible = false;<br />
neu = (Form)forms[6];<br />
neu.ShowDialog();<br />
}<br />
}<br />
}
|
|
|
|
|
Anonymous wrote:
Arraylist forms = new Arraylist(10);
Form1 for1 = new Form1();
.
.
.
forms.Insert(0, for1);
.
.
.
Are you doing this in the constructor of the forms? If yes thats the problem:
If the Form constructor constructs another form which again does this which again does this which again does this ... and there is your endless loop.
An easy way araound this would be to create a factory class which creates the forms. The first time a form is requested it can instaniate it, for every next call it should pass the already created instance to the caller (singleton).
public class FormFactory {
private Form1 _form1;
private Form2 _form2;
public Form1 CreateForm1() {
if (_form1 == null)
_form1 = new Form1();
return _form1;
}
public Form2 CreateForm2() {
if (_form2 == null)
_form2 = new Form2();
return _form2;
}
}
|
|
|
|
|
Hi, I am trying to write a program that finds the average of all prime numbers between 1 and 100 and prints the average to the screen.
But i can't use numbers from a predetermined prime numbers list.
Can any one help me?
Ryan H
|
|
|
|
|
Sounds like homework to me
Ill give you some help but unless you have a special problem you will have to implement it yourself.
1. To find all prime numbers between 1 and 100 you will have to make a loop and check every number if its a prime number (ok if you are clever you only test the unequal numbers).
2. To check if a number is prime you will have make another loop checking if the number to test can be divided by another number which is bigger than 1 and smaller than itself (again if you are clever you only test up to n/2).
3. To test if a number can be deivided by another one use the mod (%) operator. If a % b == 0 then the numbers can be divided.
4. Every successfully tested number could stored in an ArrayList.
5. After youve tested all numbers just loop through the list and caculate the average.
Just as a note to the perfectionists: I know there are better algorithms for that but for such small numbers that will do it perfectly well.
|
|
|
|
|
HOMEWORK!!!!!
Here is the *simplest* algorithm
i - Loop through all odd numbers. That eliminates all even numbers which by definition CANNOT be prime.
ii - Write a function that loops thru from 3 - sqrt(number) and if the mod results in 0 at any point then that number is not a prime. No need to test dividing by 1 and 2 since every number can be divided by 1 and you have eliminated even numbers so no need to divide by 2. You could go up to n/2 but it is unnecessary. eg. you are testing 47 for prime:
* sqrt(47) = 7 (roughly)
* if any number from 3-7 cannot divide 47 then it is surely a prime so u tested 5 numbers instead of 24.
iii - Store every successfully tested number in some sort of collection.
iv - Iterate thru the collection and do the average
|
|
|
|
|
Simplest? I don't understand this very much. Write a function that loops thru from 3 - sqrt(number) and if the mod results in 0 at any point then that number is not a prime. What??? This is really hard to understand I am only in my 4th week of programming and its moving to fast. I haven't done any programming before. Could you please help me?
|
|
|
|
|
Hey don't shout directly into my ear! Now im hearing a ringing allaround
And please explain why this algorithm should be easier to understand then mine
(its nearly the same except a bit more optimization)
|
|
|
|
|
I know I have to make a loop and check every number if it is a prime number,
But I'm still lost. I'm not sure on how to set it up. I don't know what an array list is either. This is only my fourth week in my programming class and I have never done any programming before, this stuff is really hard to understand.
|
|
|
|
|
Ok, as its Sunday and I have nothing really important to do...
public ArrayList FindPrimes(int maxNumber)
{
ArrayList result = new ArrayList();
for (int i = 3; i <= maxNumber; i += 2)
if (IsPrime(i))
result.Add(i);
return result;
}
public double GetPrimesAverage(int maxNumber)
{
return CalcAverage(FindPrimes(maxNumber));
}
public bool IsPrime(int number)
{
double max = Math.Sqrt(number);
for (int i = 3; i <= max; i += 2)
if (number % i == 0)
return false;
return true;
}
public double CalcAverage(ArrayList list)
{
double sum = 0;
foreach (int number in list)
sum += number;
return sum / list.Count;
}
Generally its the the algorithm I already stated (including some optimizations I initially didnt want you to take care of ).
I tried to split up the functionality. The function names should be descriptive enough to tell you want each part is doing. Note that IsPrime gives only valid results for uneven numbers.
As GetPrimesAverage gets an argument you can calculate the average for as much prime numbers as you want (cpu is the limit - dont test it with more than about 20 millions). To get the result for a maximum of 100 the following call had to be done:
GetPrimesAverage(100)
Do yourself the favor and read it carefully until you understand it. If you already know how to use a debugger it would be good if you just step through the code until you get it.
|
|
|
|
|
Dear Friends
I am developing my website in ASP.NET with C-Sharp I want to include my html file which contains the background image. how i can include the .html file in my index.aspx file.
Your quick response will be appriciated
Thanks
Murtuza.
|
|
|
|
|
hi,
take a look at <a href = "http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpresponseclasswritefiletopic.asp" rel="nofollow">Response.WriteFile(string)</a>[<a href = "http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpresponseclasswritefiletopic.asp" target = "_blank" rel="nofollow">^</a>]
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
to obfuscate any application on dot.net by add-ins i m geting all namespace ,class, memberfuntion,datamember.... but i m not getting the local variables and local funtions and the object derived from class... how to get that..
thanks in advance
|
|
|
|
|
Hi... i am an amateur programmer trying to do a context menu for a listbox in visual studio with C#. In the listbox there are several items and the context menu popups where ever you click in the listbox. I need that the context menu pops up only when the user right clicks a selected item from the listbox.
Please help
thanks
|
|
|
|