|
Hi!!
sorry for late..
I used Repeater control and it's working fine...(^^)
thank you so much....
|
|
|
|
|
mi working on a media player using window media player. I have a function setup on my main form where the media player object is.
public void playSong(string path)
{
label4.Text = path;
WMP.URL = path;
}
I have a class called utility that im using to pass in to the media player what I want to play. All works fine but one thing. In the class, I have to create a new instance of the object to gain access to the function.
public void playSelection(int ID)
{
OleDbConnection musLibConn = new OleDbConnection();
utility util = new utility();
musLibConn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\GeneSys\Library.mdb";
musLibConn.Open();
OleDbCommand selLib = new OleDbCommand("SELECT Path FROM Library WHERE ID ="+ID, musLibConn);
OleDbDataReader drLib = selLib.ExecuteReader();
int idxPath = drLib.GetOrdinal("Path");
drLib.Read();
Path = (string)drLib.GetValue(idxPath);
<big>frmMain frmMain = new frmMain();</big>
frmMain.playSong(Path);
}
How can I gain access withot having to create the newobject so that I can use the media player instance that stays open on the main form all the time?
|
|
|
|
|
Jon Henry wrote: frmMain frmMain = new frmMain();
frmMain.playSong(Path);
Well, this plain won't work, unless your control is static. Your best bet is to set up a delegate between the forms, so that this method calls a method on the main form. The other, hacky way, is to pass in a reference to your main form, or use Application.Forms[0], or I think there's a MainForm property, to get the main form ( you'd have to cast it to get access to the derived properties and methods );
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Could you elaborate a little on the methods between forms idea. I am a novice but if Im not mistaken, thats exactly what Im doing. The playSong method is on the main form and the playSelection method is in the class utility. IN the playSelection method, once i have the path I need I send it by way of calling playSong from the main form and passing the path. The problem is in order gain access to call the method playSong(situated on the frmMain) I have to create a a new instance of frmMain creating 2 main forms open with one playing the song and the original one sitting idle. I need to be able to reference the playSong method on the original instance of frmMain so that Im always using the same media player.
Again Im a novice s some of my terminology may be a little off.
|
|
|
|
|
OK, in the first instance, creating the second form is insane. Instead, you can pass the first form through using this, so that it becomes a variable inside the second class. This is the easy way, but not good practice.
Secondly, the right way is a delegate. A delegate is a function pointer, which can then be called in class a, but it executes code in class b. So set up a delegate that then calls a method in the main form, passing in the name of the file to start playing. If you google delegates, there's tons of examples, plenty of CP articles, etc.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
You can use the form as a data member.
frmMain mFrmMain;
public void playSelection(int ID)
{
//Your code
if(mFrmMain == null || mFrmMain.IsDisposed || mFrmMain.IsClosed)
{
mFrmMain = new frmMain();
}
frmMain.playSong(Path);
}
BTW - you are not disposing your objects (OleDbConnection or forms)
Natza Mitzi
|
|
|
|
|
Hi,
i have a Datagridview that shows a list of customers (List<customer>).
Now i have a property named selectedCustomer.
How can i bind the property to the selected row of my datagridview ?
bye jo
|
|
|
|
|
I would use the selected item event to populate the customer object when it changes. AFAIK you can't bind a property, it is not a control.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hello....
i have been used to php scripting and may i know is it possible to dynamically generate the code in the program like echoing the html code at the time of the script running and is the same process possible in c#...
|
|
|
|
|
You can use the CodeDOM classes to do this.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys
|
|
|
|
|
How to recognise a character like A , C, M,W,Q etc.
I wanted to know if there is any other algorithm for this except feature extraction and if feature extraction is the one to be used then how do i implement it in C#.
thanks in advance
|
|
|
|
|
http://www.codeproject.com/KB/GDI-plus/Image_Processing_Lab.aspx[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
You're better off buying an OCR library, this is a very complex task. The link someone else gave you sure isn't going to help much.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I was reading in Wikipedia (don't say it) about how C# is one of the languages in which you can't use variable shadowing. The article gives an example of shadowing in C++ (in which you CAN shadow variables).
However, I have been unaware of this limitation (and I think I may have used variable shadowing in the past). Just to be sure, I typed up a similar bit of code in C#, and it compiled and ran just fine:
using System;
public class test
{
public static int testing = 0;
public static void Main()
{
int testing = 1;
Console.WriteLine(testing);
Console.WriteLine(test.testing);
Console.ReadLine();
}
}
So, how is it NOT variable shadowing, if it's the same construction as the C++ example? Is it just that they renamed it something else (like "hiding")?
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
However, this will not compile:
private static void doSomething()
{
int number = 5;
if (true)
{
int number = 6;
}
}
|
|
|
|
|
Even though that DOES compile in C++, it's not quite what I was expecting. From different sites (google "variable shadowing"), variable shadowing always refers to when a variable shares its name with that of a different class, method, or struct, not if-block scope.
I agree that if-block scope is still just another level of scope (deeper than method or class scope), but it's not specified in different definitions of variable shadowing (only class/struct and method scopes are mentioned, not if-blocks).
Thank you for bringing that to my attention, I hadn't though of if-blocks. We'll see how long it lasts if I add that detail to the Wikipedia article...
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
In my experience, probably not long, then again, perhaps I am just always wrong .
|
|
|
|
|
likefood wrote: Is it just that they renamed it something else (like "hiding")?
In C++, the following code is perfectly valid
int v = 0;
if(true)
{
int v = 10;
std::cout << v;
}
std::cout << v; If you try this in C#, you will get compiler error. However, this is not called as hiding in C#. Hiding is something like this
class Base
{
public string SomeVar = string.Empty;
}
class Derived : Base
{
public string SomeVar = string.Empty;
}
|
|
|
|
|
It appears that C# does not allow shadowing from within a decision block. It has already been clarified that it won't work between inside and if-block and its outer method. And I already knew you can't shadow between case statements in a switch block (when you can with Java). However, it has no problem with it between a method and its class (or between an inner and an outer class). It would be cool if that distinction was made more clear in the documentation.
Thanks for pointing out the decision-block scenario to me, StephenWhitfield and Navaneeth!
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
likefood wrote: And I already knew you can't shadow between case statements in a switch block (when you can with Java)
To know why C# doesn't support this, write a C# code with switch case, compile it and look into the generated IL. You will see the reason
|
|
|
|
|
That is no reason, they could rename the new variable to, say, CS$0$0037 they do stuff like that all the time..
edit: quick example: if you switch on a function parameter instead of a local (a new local will be created with a funky name)
|
|
|
|
|
Is there a way to actually test a connection to the mail server without sending a test email? I figure you could send a "test" email and wait for an exception to tell if the mail server was there, but you would need a valid mailbox.
Basically how could you test a connection to a mail server, maybe not testing to see if Exchange or something was there, but just to see if you could reach that server at all?
|
|
|
|
|
Create a TCP connection to it, if it doesn't greet you it's dead. If it does greet you you could HELO it and check whether it says OK, or just decide that it's all good. Then either send a QUIT or just break the connection, if the server can't handle sudden connection breaking then they should fix it ASAP anyway so I wouldn't feel too bad about that.
|
|
|
|
|
Ohhh... I didn't even think about that.. I don't think I need to send anything, I just need to be able to connect to the server...
So..
TcpClient tcp = new TcpClient();
tcp.ReceiveTimeout = 3;
try
{
tcp.Connect(Properties.Settings.Default.smtpHost, 25);
return true;
}
catch (Exception ex)
{
return false;
}
finally
{
tcp.Close();
}
Seems to work great! Thanks
|
|
|
|
|
Hi All,
I am using .NET framework 1.1. I want to resize an array dynamically.As I am using 1.1, I can not use Array.Resize() method. I have the code to resize built in types. But my array is an array of structures.Thus following code is not working with it.It is working fine for any built-in type like int or float.Please help me to resize an array of structures dynamically.
<br />
public static System.Array ResizeArray (System.Array oldArray, int newSize) {<br />
int oldSize = oldArray.Length;<br />
System.Type elementType = oldArray.GetType().GetElementType();<br />
System.Array newArray = System.Array.CreateInstance(elementType,newSize);<br />
int preserveLength = System.Math.Min(oldSize,newSize);<br />
if (preserveLength > 0)<br />
System.Array.Copy (oldArray,newArray,preserveLength);<br />
return newArray; }<br />
|
|
|
|