|
thanks. i got it sorted out with OnReSize.
I created a class and just override the OnResize and
put my code in there.
Thank you for your ideas and help.
God bless.
|
|
|
|
|
hi im new to c# but i do have some experience with other languages
here the problem ive wrote a PSP Game that will allow users to make their own quizes (in pretty much plain text) but i would like to make an app to make it even easier (Console or whatever) this is what i have so far
using System;<br />
<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
namespace ConsoleApplication1<br />
{<br />
class Program<br />
{<br />
<br />
static void Main(string[] args)<br />
{<br />
<br />
Console.Write("How Many Questions Do You Want In This Quiz : ");<br />
string NOQuestions = Console.ReadLine();<br />
<br />
Console.Write("Enter A Question : ");<br />
string Question = Console.ReadLine();<br />
<br />
Console.Write("How Many Answers Do You Want For This Question : ");<br />
string NOAnswers = Console.ReadLine();<br />
<br />
Console.Write("Enter An Answer : ");<br />
string Answer1 = Console.ReadLine();<br />
<br />
<br />
Console.Write("Enter A Score : ");<br />
string Score1 = Console.ReadLine();<br />
<br />
Console.Write("Enter An Answer Or type No to exit the answer section : ");<br />
string Answer2 = Console.ReadLine();<br />
<br />
<br />
Console.Write("Enter A Score : ");<br />
string Score2 = Console.ReadLine();<br />
<br />
Console.Write("Enter An Answer Or type No to exit the answer section : ");<br />
string Answer3 = Console.ReadLine();<br />
<br />
<br />
if (Answer3 == "No")<br />
{<br />
Console.Write("Enter A Time : ");<br />
string Time = Console.ReadLine();<br />
Console.Write(Time + " ");<br />
Console.Write(Question + " ");<br />
Console.Write(Answer1 + " ");<br />
Console.Write(Answer2 + " ");<br />
Console.Write(Score1 + " ");<br />
Console.Write(Score2 + " ");<br />
}<br />
else<br />
{<br />
Console.Write("Enter A Score : ");<br />
string Score3 = Console.ReadLine();<br />
}<br />
<br />
<br />
}<br />
<br />
}<br />
<br />
<br />
}<br />
<br />
<br />
ok now what i need to do is to make it do either of these 2 things
1.when it asks you how many answer/question you want
i want so when the correct amount of answers has been made for it to move on to the timer
and when it done the timer create a new question and when it get to the correct amount of questions make it end
2.You type No to make it stop asking you for question or answers
here the template of a quiz i made for my app
Quiz = {<br />
{ "Question", { "Answer1", "Answer2", "Answer3"}, { Score1, Score2, Score3}, Time}<br />
}<br />
<br />
Creator = "Your Name"<br />
the brackets and speech marks must remain the same and each line is one question all the question except the last one need to have a , after it
SO COULD YOU POINT ME IN THE DIRECTION THAT I NEED TO GO THANKS
|
|
|
|
|
Hi
OK, first of all you need to make sure that the user has entered a number for the number of questions. int.TryParse can be used to turn a string into a number, or tell you if it can't be done. Then you want to create a loop, as in
for (int i=0;i<numquestions;++i) where="" numquestions="" is="" the="" int="" you="" created="" as="" per="" int.tryparse
{
="" any="" code="" put="" in="" here="" will="" be="" run="" numquesions="" times.
}
so,="" then="" your="" to="" get="" a="" question="" goes="" inside="" loop="" and="" runs="" number="" of="" times="" hoped.="" i'd="" create="" struct="" represent="" answer,="" list="" them="" add="" within="" loop.
=""
<div="" class="ForumSig">Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello,
I have a xml document like this:
< ? xml version = " 1.0 " ? >
< Accounts >
< Account ID = " 123456 " >
< FirstName > Latheesan < / FirstName >
< SecondName > Kanes < / SecondName >
< Balance > 0 < / Balance >
< OverDraftLimit > 50 < / OverDraftLimit >
< FullAddress > My Address Here < / FullAddress >
< / Account >
< / Accounts >
What i am trying to do is select one matching document node based on my XPath expression and then when found, assign each element node's value to set of strings.
So far, this is what i was able to do:
private void searchBtn1_Click(object sender, EventArgs e)<br />
{<br />
try<br />
{<br />
string fileName = "Account_Data.xml";<br />
XPathDocument doc = new XPathDocument(fileName);<br />
XPathNavigator nav = doc.CreateNavigator();<br />
<br />
XPathExpression expr;<br />
expr = nav.Compile("//Account[@ID='" + accountIDInput.Text + "']");<br />
XPathNodeIterator iterator = nav.Select(expr);<br />
<br />
nav.MoveToFirstChild();<br />
MessageBox.Show(nav.Value);<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("Error : " + ex.Message);<br />
}<br />
}
I printed the XPath Expression result using MessageBox.Show to see what the results would be like. On the message box, i saw the entire document node and it's element nodes and their values.
How do you obtain the results after running XPath expression and assign element node's value like this:
string AccountID = nav.value;
string FirstName = nav.value;
string SecondName = nav.value;
string Balance = nav.value;
string OverDraftLimit = nav.value;
string FullAddress = nav.value;
|
|
|
|
|
Nevermind, i worked it out =D
private void searchBtn1_Click(object sender, EventArgs e)<br />
{<br />
try<br />
{<br />
string fileName = "Account_Data.xml";<br />
XPathDocument doc = new XPathDocument(fileName);<br />
XPathNavigator nav = doc.CreateNavigator();<br />
<br />
XPathExpression expr;<br />
expr = nav.Compile("//Account[@ID='" + accountIDInput.Text + "']");<br />
XPathNodeIterator iterator = nav.Select(expr);<br />
<br />
iterator = nav.Select(expr);<br />
<br />
if (iterator.MoveNext())<br />
{<br />
XPathNavigator nav2 = iterator.Current.Clone();<br />
<br />
string accID = (nav2.GetAttribute("ID", ""));<br />
nav2.MoveToFirstChild();<br />
string firstName = (nav2.Value);<br />
nav2.MoveToNext();<br />
string lastName = (nav2.Value);<br />
nav2.MoveToNext();<br />
string currentBalance = (nav2.Value);<br />
nav2.MoveToNext();<br />
string overDraftLimit = (nav2.Value);<br />
nav2.MoveToNext();<br />
string = fullAddress = (nav2.Value);<br />
}<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("Error : " + ex.Message);<br />
}<br />
}
|
|
|
|
|
hi all !
i'm pretty newbie in the coding world and have a little problem that i cant find a solution
i have 2 richtextbox. the first is to write the text and the second to see it (read only)
so there is my code
<br />
<br />
private void button2_Click_1(object sender, EventArgs e)<br />
{<br />
DateTime dt = DateTime.Now;<br />
string str1 = dt.ToString("H:mm:ss").PadRight(10);<br />
string str2 = richTextBox1.Text;<br />
string str3 = str1 + str2 + "\n";<br />
richTextBox2.AppendText(str3);<br />
richTextBox1.Clear();<br />
the real goal is simple, i want the time to be wrote at the start of every text add. Thats why i made it like that. My problem is the "\n" at the end of the string 3. If i dont put it, then the next text is wrote a the end of the first one. If i put it and the user finish is text and press enter then the click button, i have a empty line (witch i dont want it). The richtextbox2 gonna be print at the end and its a report to be showed to the boss as a clean copy so empty lines need to be removed.
if someone can help me
btw, sorry for my english, i know i'm bad but what can i say ? i'm talking in english like in coding
thanks
|
|
|
|
|
Um, have you tried this?
DateTime dt = DateTime.Now;<br />
this.richTextBox1.SelectedText = dt.ToString("H:mm:ss").PadRight(10);
|
|
|
|
|
i just tried but it give me the time after the text
i'm still working on it
thanks for the answer though
|
|
|
|
|
hi, i'm not sure anymore, i've confused myself.
i have this in a com-visible dll:
<br />
public class Interop : ITouchlibInterop<br />
{<br />
public virtual void fingerDown()<br />
{<br />
}<br />
}<br />
now in another file, my interface (winforms);
<br />
class Touch : Interop<br />
{<br />
public override void fingerDown()<br />
{<br />
}<br />
}<br />
the first class (Interop : ITouchlibInterop) is called from a c++ dll via COM. then i want my derived class - that is my interface handle the 'event' and not the com-visible dll.
now for my question:
will Touch.fingerDown() be called when Interop.fingerDown() is called?
rather have something you don't need, than need something you don't have
|
|
|
|
|
Hi,
Interop a=new Touch();
a.fingerDown();
will call Touch.fingerDown() although a is declared only as an Interop object.
BTW you should start public methods with an uppercase letter.
|
|
|
|
|
thanks again for you help
rather have something you don't need, than need something you don't have
|
|
|
|
|
Hello guys,
i am having a problem using Delegates,
now i am working on an application where i have a label on a form and then i have a separate class in separate CS file (ie., Form1.cs and myClass.cs)
what i am trying to do : i wanted to update label1.Text every tick of a timer with the format 00:00 next tick 00:01, then next tick 00:02 and so on
so in my Class there is a timer(System.Timers.Timer/System.Threading.Timer/System.Windows.Forms.Timer) and i am trying to update the label1 in form1 using the following :
Form1 :
-----------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void setlabeltext(Label lbl, String strValue)
{
lbl.Text = strValue;
}
private void Form1_Load(object sender, EventArgs e)
{
Class1 myClass = new Class1();
myClass.startCall();
}
}
}
myClass:
--------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Timers = System.Windows.Forms.Timer;
namespace WindowsApplication2
{
class Class1
{
Form1 form1 = new Form1();
Timers timoz = new Timers();
public void timoz_Tick(object sender, EventArgs e)
{
ThreadSafeSetLable(form1.label1, DateTime.Now.Subtract(DateTime.Now).ToString());
}
private void ThreadSafeSetLable(Label lbl, string value)
{
if (form1.InvokeRequired)
{
form1.Invoke(new SetString(form1.setlabeltext), new object[] { lbl, value });
}
else
{
form1.setlabeltext(lbl, value);
}
}
private delegate void SetString(Label txtBox, string strValue);
public void startCall()
{
timoz.Interval = 1000;
timoz.Start();
timoz.Tick += new EventHandler(timoz_Tick);
}
}
}
this is not working i dont know why , it compiles no problem , in the debugging the label1.text is changing to 00:00:00 but runtime i dont see that , plus the form1.InvokeRequired never gets to "true" , i do realize that i am missing something but i dont know what , can i have help on that ? thanx
T.R.
|
|
|
|
|
Tamer A.Rahman wrote: Form1 form1 = new Form1();
I'm not sure what you hope this to do, but it will create a new instance of Form1, which is in no way related to the one that is visible on your screen.
Your controls should also not be made public on the class, delegates are used to avoid such nastiness. A delegate defined in class1, should call a method in form1, and pass in the string to set. The method should assign the string to the label, and class1 calls the delegate whenever it likes, via your timer or whatever.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
well, thank you for the reply,
i got it already
it was the wrong approach from the begining and i fixed it
thanks for all the help anyway
|
|
|
|
|
I am using VS2005 with SQLServer Express Edition. Select SQL statement work fine but not Insert or update. Is there something am doing wrong?
Sample insert code.
DataSet.DatabaseDataSetTableAdapters.SaleTransactionTableTableAdapter SaleTransAdapter = new DataSet.DatabaseDataSetTableAdapters.SaleTransactionTableTableAdapter();
SaleTransAdapter.Insert(7, (decimal)NetTotal, DateTime.Now);
Nana
|
|
|
|
|
i add the same problem with i think.
the problem is when you create the DB, it make a copy of it in your bin/debug forder and every update are in this DB
the one you create is the basic one and every time you run the debugger, he takes all the info in the basic one to overwrite the bin/debug one but the screen result show you the bin/debug DB.
so, it look like the add you made are not working
in your db explorer, create a new connection and link it to the bin/debug one then when you add something, check in this one
hope it help you !
have a good one
|
|
|
|
|
Thank you for your help. I am afraid to say its still not working. Only select statements work after i have manually populated the database. Insert and updates still don't. i added a connection to the copy in the debug. It also has the same data as the one in the local folder. Insert still not working on that one too. I will appreciate anymore suggestions
Nana
|
|
|
|
|
Well thanks for your suggestion. I tried it and its still not working. Insert and update statement do not work on the database cope in the debug directory too. The select statement works if i populate the database manually. I create insert and update commands to no success. I will appreciate anymore sugestions. Thanks
Nana
|
|
|
|
|
You need to set insert and update commands
|
|
|
|
|
Well thanks for your suggestion. I tried it and its still not working. Insert and update statement do not work on the database cope in the debug directory too. The select statement works if i populate the database manually. I create insert and update commands to no success. I will appreciate anymore sugestions. Thanks
Nana
|
|
|
|
|
Hi
I'm currently developing a windows application in c#. I have a set of static libraries written in c++ which I used in a VC++ application. The libraries have numerous classes which would be useful. So I'd like to instantiate object of these classes in my c# code. The question is should I discard the libraries and re-write the code or can I make this into managed code or can I leave it and use it as is.
Any suggestions would be great!
Cheers
|
|
|
|
|
From managed code in C# you can only use PInvoke to call 'C' functions exported from DLLs. If you have exported C++ classes you cannot interact with them at all using PInvoke.
Using VC++/CLI in a mixed mode project you can access both the managed world and the native world. If you use C++/CLI to wrap the old classes in managed classes you will be able to reuse the code as is and expose it to C# code through the new managed class or classes. There are many articles here and on MSDN about C++/CLI and there is a forum for it on CodeProject as well.
led mike
|
|
|
|
|
hi
i need a Vs2005 richTextBox component that has background image capability.
thanks
|
|
|
|
|
I create stord procedure in SQL 2000
Select_Cost
@day1 int,
@month1 int,
@year1 int,
@day2 int,
@month2 int,
@year2 int
AS
Select aa,ab,autoclave,fz,ez,liquidglue,pearlglue,hh,pva
from CostDetails
where
datepart(day, costdate ) >= @day1
and
datepart(month, costdate ) >= @month1
and
datepart(year, costdate ) >= @year1
and
datepart(day, costdate ) >= @day2
and
datepart(month, costdate ) >= @month2
and
datepart(year, costdate ) >= @year2
GO
and i want shoe result in Crystal report
i try it in C#.net 2005 and write this code but crystal report load empty :
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con =new SqlConnection();
con.ConnectionString = "Data Source=.;Initial Catalog=cost;Integrated Security=True";
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "Select_Cost";
SqlParameter par1 = new SqlParameter("@day1", dateTimePicker1.Value.Day);
SqlParameter par2 = new SqlParameter("@month1", dateTimePicker1.Value.Month);
SqlParameter par3 = new SqlParameter("@year1", dateTimePicker1.Value.Year);
SqlParameter par4 = new SqlParameter("@day2", dateTimePicker2.Value.Day);
SqlParameter par5 = new SqlParameter("@month2", dateTimePicker2.Value.Month);
SqlParameter par6 = new SqlParameter("@year2", dateTimePicker2.Value.Year);
cmd.Parameters.Add(par1);
cmd.Parameters.Add(par2);
cmd.Parameters.Add(par3);
cmd.Parameters.Add(par4);
cmd.Parameters.Add(par5);
cmd.Parameters.Add(par6);
SqlDataAdapter datadp = new SqlDataAdapter();
datadp.SelectCommand=cmd;
ChamberDataSet ds = new ChamberDataSet();
con.Open();
datadp.Fill(ds);
con.Close();
crystalReportViewer1.Visible = true;
CrystalReport1 report1 = new CrystalReport1();
report1.SetDataSource(ds);
this.crystalReportViewer1.ReportSource = report1;
THANK U
|
|
|
|
|
Afternoon All,
This has maybe been asked a million times so apologies in advance.
Does anyone have a tried and tested way of converting a decimal to a fraction (including negative decimals) or better still can you point me in the direction of an article explaining how to do this? I have tried google but can find nothing on C#. I did convert a program written in VB, but only to find that the logic therein was wrong.
Really appreciate any help
Thanks in advance
Colin
|
|
|
|