|
Do you have any recommendations for this case ?
|
|
|
|
|
How about moving the code inside case 65 into a function and calling that from both places?
|
|
|
|
|
Yes, that's what I would do.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
because i have like 100 cases like that and i prefer not make a case into a function
|
|
|
|
|
dec82 wrote: i prefer not make a case into a function
May I know why?
|
|
|
|
|
dec82 wrote: i prefer not make a case into a function
OK, you're really doing it the wrong way then. You're making a single monolithic method that does everything instead of breaking up the code into FAR more manageable, supportable, and extendable pieces. I'm afraid if you were working for me, I'd have to fire you for doing that. No joke...
I'd probably have to question the validity of using a Switch with 100 cases in it too. But, I say that without knowing anything about what your app does of its data model. If you were using a switch on an integer value, I'd probably look into using delegates stacked in an array or hashtable to shorten up the code and increase its performance. You know, using the switch value as an index into an array? But, like I said, it's only a thought based on no knowledge of what your code is doing or its requirements.
|
|
|
|
|
Well, if you're determined to write bad code, why are you posting about it here ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Actually break; cause the switch to exit and continue with the codoe afterwards.
Leaving it and not writing anything, but simply adding other case will automatically cause the switch to move on and execute all code until the next break;
Thus if you have somethng like this:
switch(number)
case 1:
break;
case 2:
case 3:
break;
case 4:
break; the program will do the exact same for 2 and 3.
If you don't want it to do anything different for 2, you might as well leave that case empty, so it immediately goes to the next code before the break;
|
|
|
|
|
i tried this......
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this is the transperant colors.....once i put this its become totaly transparent....i don't want like that...i want like vista aero.....
even when i change the colour of this red...63....etc become another colours....
is there a way to add opercity function only to background ......???
something like (this.BackColor or backImage as opercity 0.90.... )
A S E L A
|
|
|
|
|
S K Y wrote: System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
Wow - that's kind of ridiculous. Why all the casting ?
S K Y wrote: this is the transperant colors.....once i put this its become totaly transparent....i don't want like that...i want like vista aero.....
What are you talking about ? This is a grey, it's not transparent at all. Do you mean it's the mask color ?
S K Y wrote: is there a way to add opercity function only to background ......???
Not really, no. You'd need to use an opacity mask, which I believe is supported, or you'd have to write code to create one. An opacity mask is where you have another bitmap where each matching pixel tells you the opacity of the same pixel on the main image.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
i want to make clear what u r tell...
r u telling to creat using code plane image and sent the opercity of that image. after that i should add that image as background image as my form....am i correct...???
A S E L A
|
|
|
|
|
S K Y wrote: is there a way to add opercity function only to background ......???
No.
But you can separate the background from the foreground, and draw each independently from the other, setting the alpha channel for the background to something lower than 1.0, while drawing the foreground with an alpha channel value of 1.0. However, that's not like Aero. Aero does the entire panel at the same alpha value.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
do u have any link discribing more about this or...how should i search....i mean search as???
A S E L A
|
|
|
|
|
Think about it - if you want to draw a control yourself, what do you need to do? You need to override the functionality to draw the control.
And yes, you need to search - I recommend google.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi all...
I've GridView that contains around 10000 records. and I want to disable JavaScript doPostBack (Sorting and pageing)
I found many articles but I don't know who is the best
what is the best way to make it available for SEO?
thanks...
|
|
|
|
|
Feddo04 wrote: I've GridView that contains around 10000 records. and I want to disable JavaScript doPostBack (Sorting and pageing)
With so much data is disabling paging really a good idea?
Feddo04 wrote: I found many articles but I don't know who is the best
Since you've not told us what articles you've found we can't really comment on them. I suggest trying out what they say and seeing what happens. Experimentation is an excellent form of learning.
Feddo04 wrote: what is the best way to make it available for SEO?
SEO? Search Engine Optimisation?
Allow search engines to find it
|
|
|
|
|
Hi Colin!
thanks for reply...
I think you didn't got me.
Ok....let me explain to you again.
of course I want to enable paging and sorting...("Who will put 10000 records without paging???!!!")
what I mean is the standard paging GridView is a Java Script. and then it'll not recognized by Google search or other search engine(SEO ("Search Engine Optimisation"))
So how to use GridView with a custom Paging ("without Java Script doPostBack") that what I didn't use it before.
Thank you...
|
|
|
|
|
Feddo04 wrote: I think you didn't got me.
That's why I was questioning what you appeared to be doing.
Feddo04 wrote: So how to use GridView with a custom Paging ("without Java Script doPostBack") that what I didn't use it before
Don't use a GridView. Create your own version that does what you want.
I tend to end up using repeater controls because they are so much easier to work with and I actually know what it is doing.
|
|
|
|
|
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
|
|
|
|