|
try resizing your forms in design time.
think that could help... i dont see anything wrong in the posted code.
Greetings
|
|
|
|
|
I tried resizing the child form but it ended up being too small in the main form window which is not the desired goal. no matter how I resized it I would have the child form either too small and get the scroll bars.
Thanks
|
|
|
|
|
Set the WindowState of the child form to Maximized. This means that the child window will show maximized in the MDI frame - which will put the close/minimize/maximize buttons in the MDI frame window.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi guys
I wanna know how I could make the following function more generic and stop writing tedious code...
My current example function:
<br />
public SqlCommand SetupCommand()<br />
{<br />
SqlCommand cmd = new SqlCommand();<br />
cmd.CommandText = "SELECT * FROM Test";<br />
cmd.CommandTimeout = 180;<br />
<br />
return cmd;<br />
}<br />
The above snippet of code will return a SqlCommand object. However there is cases where I would like this very same method but this time around returning a OleDbCommand object.
Is there a way to make this method more generic to be able to return any Command types e.g SqlCommand, OleDbCommand without having to re-write code all the time.
I guess I'm searching for something similar to IDataReader that can return either SqlDataReader or OleDbDataReader.
Thanks in advance.
R.
|
|
|
|
|
Wouldn't the easiest way be:
<br />
public DbCommand SetupCommand(bool isSql)<br />
{<br />
if(isSql)<br />
{<br />
}<br />
else<br />
{<br />
}<br />
return cmd;<br />
}<br />
There is no knowledge that is not power. - Mortal Kombat
|
|
|
|
|
|
|
If you are using .NET 2, take a look at the DB Provider classes that were introduced. These classes, such as DbCommand[^] are intended to provide you with a relatively database agnostic way of working with your data. You can get more detailed information here[^].
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi
Try using the following code
that use generics in order to construct the desired type sqlcommand
class Program
{
public static T SetupCommand<T>() where T : IDbCommand, new()
{
T cmd = new T();
cmd.CommandText = "SELECT * FROM Test";
cmd.CommandTimeout = 180;
return cmd;
}
static void Main(string[] args)
{
SqlCommand sqlClientCmd = SetupCommand<SqlCommand>();
OleDbCommand oleDBCmd = SetupCommand<OleDbCommand>();
}
}
-- modified at 6:21 Friday 5th October, 2007
|
|
|
|
|
Hello. I want to post to a blog using C#, any have an idea of how to do that?
Thanks a lot !!!
|
|
|
|
|
That's insufficient information to give you a meaningful answer. What blog hosting service are you trying to post a blog to? Services like Blogger, for example, give a public API you can call via web services.
I recommend you figure out which blog hosting service to publish a blog post to, then go to that service's developer API site and figure out how to call their web service APIs via .NET.
|
|
|
|
|
Do you mean that you want to write a blogging engine in C#? If so, have a search on this site for Marc Clifton's articles on creating a simple blogging engine.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I want to create a menubar or content box that sides up out of the way at the click of a button. It doesn't have to be a menu, per se, I can just place images and/or buttons in a sliding area. I just want to be able to click and have it slide up, or down, giving me access to the buttons when I need them.
|
|
|
|
|
hi there,
i put all the data in byte[], now i wanna read it like binary reader
is there any way?
Becoming Programmer...
|
|
|
|
|
Yeah,
Initialise a MemoryStream from the array, and then use the BinaryReader on that.
Regards,
Rob Philpott.
|
|
|
|
|
thanks but my problem solved
Becoming Programmer...
|
|
|
|
|
If you already have an array of bytes, then... what's the problem?? For example you can iterate these bytes using the for statement.
for (int i = 0; i < arr.Length; i++) {
byte myByte = arr[i];
}
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Hi,
I need to manage a treeview control with a vertical scrollbar control. I can't use the default scrollbar of the treeview and so I have to disable scrollbars on the treeview and use an external vertical scrollbar. Is this possible?
|
|
|
|
|
Hi guys
How can I delete all occurrences of the word 'test' from a string
I.e. String Before: This is a test to delete all occurrences of the word test
String After: This is a to delete all occurrences of the word
Please give me some guidelines here.
Thanks
R
|
|
|
|
|
You can use split, like this:
string myString = "this is a test waffle";
string temp[] = myString.Split("test ");
myString = "";
foreach(string str in temp) {
myString += str;
}
Then, after all that, your string should be "this is a waffle".
|
|
|
|
|
what you could do is keep it simple
use string.Replace.
ex:
string x = "This is a test,test";
string y = x.Replace("test","");
Console.WriteLine(y);
output should look like "This is a , "
have fun
Kaine
|
|
|
|
|
Damn, string.Replace. How could i forget that. Oh well, time to go methinks.
On a side note, i appear to have found a new forum to live on for a while. Who would have thought it'd be here?
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Thanks to both of you that replied!!
R
|
|
|
|
|
But what if you were to remove a word like '{test}' including the braces?
|
|
|
|
|
Nevermind I got it now, I'm just being stupid today...
Thanks again guys!
|
|
|
|