|
Just run a query on the database and add a WHERE clause to limit your results.
You will get a dataset back and then bind that to your datagrid or datagridview.
If you don't know how to do either of these, go back to school.
|
|
|
|
|
Can you please tell me whether this query is correct,when i'm trying this query error is coming.
String query = "select * from info where EndDate= " + DateTime.Today.ToString ();
|
|
|
|
|
Hey im back with a new questions / problems
Question 1:
I have a image that is in a picturebox which is called pictureBox1
I want to read monstersetbase.txt and add small ellipses to my image. The position of the ellipse comes from my monstersetbase.txt. The image is 256x256 and the coordinates is example 125x150.
I figured out a way to write a ellipse on the picturebox. It looks like this:
public void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
System.Drawing.Graphics g = e.Graphics;<br />
g.DrawEllipse(System.Drawing.Pens.Red, 125, 150, 2, 2);<br />
}
And on my form load:
public void Form1_Load(object sender, EventArgs e)<br />
{<br />
pictureBox1.Paint += new PaintEventHandler(this.pictureBox1_Paint);<br />
this.Controls.Add(pictureBox1);<br />
}
Now my problem is that I cant seem to figure out how to read the txt file properly when I need all the data
If I use for example:
public void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
String line;<br />
String data;<br />
<br />
System.Drawing.Graphics g = e.Graphics;<br />
<br />
using (StreamReader sr = new StreamReader(Convert.ToString(@fileLocation)))<br />
{<br />
while ((line = sr.ReadLine()) != null)<br />
{<br />
data = Convert.ToString(line);<br />
<br />
String[] piecesMap = data.Split('\t');<br />
<br />
float xCord = float.Parse(piecesMap[3]);<br />
float yCord = float.Parse(piecesMap[4]);<br />
<br />
g.DrawEllipse(System.Drawing.Pens.Red, xCord, yCord, 2, 2);<br />
}<br />
}<br />
<br />
}
then im getting the error:
Index was outside the bounds of the array.
Any suggestions?
My monstersetbase.txt:
3<br />
0 0 30 78 60 240 240 -1 5
1 0 30 185 132 185 132 -1 10
2 0 30 183 128 188 135 -1 10
3 0 30 10 10 240 240 -1 12
4 0 30 10 10 240 240 -1 8
5 0 30 185 132 185 132 -1 7
6 0 30 132 83 132 83 -1 10
7 0 30 183 128 188 135 -1 6
8 0 30 132 83 138 90 -1 10
end<br />
1<br />
9 33 10 85 162 95 168 -1 5
10 29 30 40 113 45 116 -1 3
11 41 5 126 160 125 161 -1 2
12 38 5 106 161 111 160 -1 2
end
78 and 60 is the x and y coordinates in the text above.
Question 2:
After I insert the ellipse I want it to be "link" like when I click on it something happens
I also want to display a tooltil when I have the mouse over my ellipse is that possible?
|
|
|
|
|
Why are you using float.parse on ints ? You have one line in each that doesn't have 4 chars, so it seems you should check your array for 4 elements first. That's always wise anyhow.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thank you for the answear(s)
Now I got it writing on the picturebox and when clicking on ellipse it shows a messagebox
But it only works for the last ellipse because the variable gp changes <.<<br mode="hold" />
Any idea?
Here is the code:
public void readFileToPaint()<br />
<br />
{<br />
<br />
string line;<br />
<br />
string data;<br />
<br />
string fileLocation = @"D:\msbEditor\monstersetbase.txt";<br />
<br />
using (StreamReader sr = new StreamReader(Convert.ToString(@fileLocation)))<br />
<br />
{<br />
<br />
while ((line = sr.ReadLine()) != null)<br />
<br />
{<br />
<br />
<br />
line = line.TrimEnd();<br />
<br />
<br />
if (line == "") continue;<br />
<br />
data = line;
<br />
<br />
String[] piecesMap = data.Split('\t');<br />
<br />
<br />
if (piecesMap.Length == 1) continue;<br />
<br />
Rectangle rect = new Rectangle(Convert.ToInt16(piecesMap[3]), Convert.ToInt16(piecesMap[4]), 4, 4);<br />
<br />
gp.AddEllipse(rect);<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
public void pictureBox1_Paint(object sender, PaintEventArgs e)<br />
<br />
{<br />
<br />
Graphics g = e.Graphics;<br />
<br />
g.DrawPath(new Pen(Color.Red), gp);<br />
<br />
}<br />
<br />
private void Form1_Load(object sender, EventArgs e)<br />
<br />
{<br />
<br />
readFileToPaint();<br />
<br />
pictureBox1.Paint += new PaintEventHandler(this.pictureBox1_Paint);<br />
<br />
this.Controls.Add(pictureBox1);<br />
<br />
}<br />
<br />
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)<br />
<br />
{<br />
<br />
if (gp.IsVisible(e.X, e.Y))<br />
<br />
{<br />
<br />
MessageBox.Show("");<br />
<br />
}<br />
<br />
}
|
|
|
|
|
You need to keep a list of all the ellipses and iterate over them, instead of just keepin ghte last one
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Any idea of that?
I cant seem to think of a way :x
gp is defined here:
GraphicsPath gp = new GraphicsPath();
|
|
|
|
|
Good evening Everyone
i have the following string in my connection string.
Server=VUYISWA-57F1183\SGICORNETGS01
Now from the above code,the name of the SQL server has a "\" character and C# compiler is Complaining about the Character and the connection string in quotes. How can i enclose it, in a manner that the compiler does not recognise it as a Special character.
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
hi
there are 2 possibilities to suppress escape-sequences
1.: double backslash:
Server="VUYISWA-57F1183\\SGICORNETGS01";
2.: the @ - sign:
Server = @"VUYISWA-57F1183\SGICORNETGS01";
greets
m@u
|
|
|
|
|
|
Thank you very
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Glad to help you
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
hi all,
i'm trying to get information from my database. When the product is shown on the web page it should have the right language in the product description...if user have choosen finnish language I want the product description be in finnish..
now it's build and it's shows just the e.g("productDescriptionFin") if the FIN language is choosed...in the textbox...
in the db [product] i'h primary key for productId and then columns like productDescriptionENG, productDescriptionFIN, productDescriptionGER, productDescriptionRUS and productDescriptionSWE.
here is the codebehind productInfo_1.aspx.cs
protected string GetDescription(object productId)
{
string strDescription = "ProductDescription";
if (Thread.CurrentThread.CurrentCulture.Name.ToLower() == "fi-fi")
{
strDescription = "productDescriptionFIN";
}
else if (Thread.CurrentThread.CurrentCulture.Name.ToLower() == "en-us")
{
strDescription = "productDescriptionENG";
}
else if (Thread.CurrentThread.CurrentCulture.Name.ToLower() == "sv-se")
{
strDescription = "productDescriptionSWE";
}
else if (Thread.CurrentThread.CurrentCulture.Name.ToLower() == "de-de")
{
strDescription = "productDescriptionGER";
}
else if (Thread.CurrentThread.CurrentCulture.Name.ToLower() == "ru-ru")
{
strDescription = "productDescriptionRUS";
}
return strDescription.ToString();
//TextBox desc = new TextBox(productId[strDescription](), productId["productId"]());
//return desc;
//ListView desc = new ListView(productId[strDescription].(), productId[strDescription].ToString());
//return desc;
}
I display the product info on a ListView with a textbox inside...
<asp:Textbox Style="position: static"
ID="tbDescrProductInfo"
runat="server" Width="245px"
TextMode="MultiLine"
Text='<%# GetDescription(Eval("productId")) %>' ReadOnly="True"></asp:Textbox>
so i wonder if any one can give me some tips or correct me if i'm going far to wrong in the code....or should I do something in the page_Load event??
plz max in sverige
|
|
|
|
|
|
okay so I am writing a c# program that will verify a user exists in our edirectory and then launch an application. basiaclly I am trying to avoid locking out the user from novell and not let the user use the application during their grace login period (when they need to chagne their password). Authenticating the user is no problem but i haven't been able to figure out how to read specifically "loginIntruderAttempts" and "loginGraceRemaining" attributes. Another words I would like to end up with something to the effect if user has x # of "loginIntruderAttempts" throw error. if "loginGraceLimit" != "loginGraceRemaining" for user throw error. Any help or guidance with this would be highly appreciated.
c# noobie
|
|
|
|
|
if (tn.Tag is DataNodePrimitive<string> )<br />
{<br />
DataNodePrimitive<string> dnp = (DataNodePrimitive<string> ) tn.Tag;<br />
<br />
dataEditorControl1.SetData<string>(tn.Text, dnp.Data);<br />
}
replace all occurances string with any type.
I've spent a good hour trying to work out how instead of testing if an object is DataNodePrimitive<string> , or DataNodePrimitive<int> , how it could be generalised to DataNodePrimitive<T>
Say I have an array of supported Types (Type[]), and i want to test if the tag is of DataNodePrimitive<Type[i]>, how on earth could I write code to do that?
I want my code to be as extendable as possible without having to write more.
Thanks,
Ben
|
|
|
|
|
You cannot make code in a class generic due to the fact that generics are resolved at compile time.
If the code is part of an object then it can be.
public class DataNodePrimitive<t>
{
...
public void SomeProcesss
{
DataNodePrimitive<t> dnp = (DataNodePrimitive<t>) tn.Tag;
...
}
}
MyProgram
/....
DataNodePrimitive<string> mynode = new DataNodePrimitive<string>();
</string></string></t></t></t>
However if the code is just in your program and you expect to have a runtime evaluation, that will not work. You need to create a method of the different types that T can be and overload the method call.
|
|
|
|
|
Well, in the end, I made a Class called DataNodePrimitive that DataNodePrimitive<t> extends. DataNodePrimitive is now just a class that has Data being an object. DataNodePrimitive<t> just ensures that it is type safe - but now I don't use it anywhere in the program for the fact I need full runtime support.
|
|
|
|
|
Is there a class or method in BCL which lets me view the logical ports opened and currently listening to??
Som
|
|
|
|
|
|
Hello,
I have read many forums and some posts on CodeProject but still have nto figured this out. I want ym application to send keystrokes to an application. At the moment it can be the currently focusses application. Any code samples will be helpful, if you do post code please insert the headers i need... i think that's way my current code is not working.
Thank you
- Droz -
___ ___
/\/\ /\ | |
|
|
|
|
|
What have you tried so far? Also, are you sure you are posting to the right forum? I mean, you're talking about headers and stuff?
|
|
|
|
|
If you want to achieve this in C then it is wrong forum. If you want it in C# then use SendKeys class
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Okay, I was cornered by deprecation. I must handle large images in my application, and System.Drawing is just not fast enough. Graphics.DrawImage() with source and destination rectangles seemed to be the best way, but even that slows down terribly when much zooming is involved.
I remembered that DirecrDraw would solve this problem, but that's deprecated, and the docs told me I should do it in 3D instead. Not that it matters, since my Managed DirectX is deprecated in favor of XNA anyway. Now, XNA doesn't work together with Visual Studio as I understand it, and the user would need to download extra framweorks anyway.
So, is there a way to use up to date hardware acceleration technologies in Visual Studio under .net? What is supported and what is not? I'll need this software running for years to come, and I might even want to modify it in the future. It would be very unpleasant if the technology it's built on would turn obsolete anytime soon.
|
|
|
|
|
Well on the form you can set DoubleBuffered to true. I've noticed that in one of my games it decreased drawing by quite a bit.
|
|
|
|