|
Hi,
first you should know on which object do u want to draw the line
such as the form or panel or whatever..
Then create a graphics object for that object and then using that
Graphics object draw the line
e.g
if you want to draw the line on the form
then create the graphics using the CreateGraphics method and
then use the DrawLine() method to draw the line
Hope You get benefited by the above information
Thanks
Pramod
|
|
|
|
|
Hello there
I have dataSet containing two relational tables. Say Parent and Child. Now when I assign the Datasource of DataGrid to Parent Table then Child Table automatically attaches and a plus (+) comes with each row containing childs rows from child table. I dont wont to diplay those as I have another grid diplaying the childs.
Can any one help me how to get rid of this.
|
|
|
|
|
Change your datagrids datasource property to be = parent table and not the dataset
|
|
|
|
|
its already the parent table only like this
dg.datasource=dataset.tables["parent"];
even then it shows the child..
any comments ?
|
|
|
|
|
hmmm...not sure really - what about setting the DataMember
i.e. dg.DataMember = "parent";
or clearing all the relations on the dataset i.e. dataset.Relations.Clear();
|
|
|
|
|
hi,
i want to set a reference of a member variable of a class to a variable passed by reference in one of its methods how to do it
Descriprion:
i am using a dll that has System.Windows.Forms.PictureBox Image; declared as a private member and many of its functions are modifyung this variable, now i want to pass a referece of a picturebox on my form to this dll and i want it to be updated when any of the functions of dll change Image variable.
How to do it
Regards,
Arus
|
|
|
|
|
Hello,
Use ref keyword. Please see MSDN for more help on ref.
HTH. Cheers
Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net
|
|
|
|
|
I have the following piece of code.
private string strName = null;
if(txtName.Text.Trim() != "")
strName = txtName.Text.Trim();
Isn't there a way to convert and assign the value of txtName to strName like in a convert function? I mean if it is empty assign null to strName, or assign it the value of txtName to strName?
The reason why I ask is because I have about 30 such tests and it takes a lot of space, or number of lines.
Regards
|
|
|
|
|
You can make your own method which can do this for you... a static utility method. Something similar to following code snippet
public static string GetString(string textBoxString)<br />
{<br />
if(textBoxString.Trim() != string.Empty)<br />
return textBoxString.Trim();<br />
return null;<br />
}
Usage:
string strName = MyClass.GetString(txtName.Text);
HTH. Cheers.
Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net
|
|
|
|
|
You can "bind" the variable to the textbox. Use something like
class MainForm : Form
{
string strName;
TextBox txtName;
public MainForm()
{
InitializeComponent();
txtName.DataBindings.Add("Text", this, "strName");
}
}
This way, when the dialog closes with DialogResult.OK, whatever is in txtName.Text will be available in strName. When the dialog loads, it's the other way around, whatever is in strName gets set as txtName.Text.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
And if it is empty then it will automatically have the value of null? But doing it your way, if the user types in nothing, but presses the spacebar once or twice, then because there is no text, it must assign it null.
|
|
|
|
|
Well, when you use the string, you can always use it after Trim()ing. The only advantage my code offers is that it saves the trouble of manually setting and getting the value of strName.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi,
I need to ask a similar question with regards to adding a SQL parameter.
Lets say after conversion the variable strName is null.
If I do the following:
SqlParameter paramName = new SqlParameter("@Name", SqlDbType.NVarChar, 150);
paramName.Value = objPrimeAgency.Name;
objCmd.Parameters.Add(paramName);
objPrimeAgency.Name is the property that returns the value of strName. @Name may contain null. When inserting this parameter to the table, will it contain a null? Is this similar to that DBNull value (can't remember exactly what it is)? Must I then individual check to test if null, other wise add the contents to value?
And then the value of the field. If a variable strName has a length, how do I specify this? Classisc ASP I used Len(strName). And secondly, if strName is null, how do I specify a length for it?
Regards,
Brendan
|
|
|
|
|
ma se wrote:
@Name may contain null. When inserting this parameter to the table, will it contain a null? Is this similar to that DBNull value
No, null is not similar to DBNull.Value
ma se wrote:
If a variable strName has a length, how do I specify this?
strName.Length property will do.
ma se wrote:
if strName is null, how do I specify a length for it?
You can not get properties of the null objects as it always results in NullReferenceException. It'll be better to put in a null check, and if true assign DBNull.Value instead of the length of the string.
HTH.
Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net
|
|
|
|
|
Thanks for the reply.
I just want to get back to your other method you mentined a couple of days:
Method:
public static string GetString(string textBoxString)<br />
{<br />
if(textBoxString.Trim() != string.Empty)<br />
return textBoxString.Trim();<br />
else<br />
return null;<br />
}
Usage:
string strName = MyClass.GetString(txtName.Text);
Your return type is a string. If it containe a null, won't it complain because your return type is a null?
If I want to create a similar function like this to return DBNull.Value, can I do the above mentioned if, if enmpty, the I return DBNull.Value? Is this the right way to coding it?
Maqsood Ahmed wrote:
strName.Length property will do.
What if it is an int value?
Maqsood Ahmed wrote:
No, null is not similar to DBNull.Value
When I have a variable that is null and add it to my table, then it seems to add a null value to the field, nulls values look like <null> in SQL Server 2000?
Regards
|
|
|
|
|
Hello,
First of all, null is not a datatype, it is a keyword which represent null reference. A null reference is reference which does not refer to any object. Also null is the default value for all reference-type objects.
ma se wrote: If I want to create a similar function like this to return DBNull.Value, can I do the above mentioned if, if enmpty, the I return DBNull.Value? Is this the right way to coding it?
Yes you can do the same for DBNull. You will have change the signature of the method to
public static DBNull GetString(string textBoxString)
ma se wrote: What if it is an int value?
I could not understand this question.
ma se wrote: When I have a variable that is null and add it to my table, then it seems to add a null value to the field, nulls values look like in SQL Server 2000?
It is DataColumn 's implementation which treats null as DBNull.Value . Therefore it'll save the null values in the DataTable to SQL Server 2000 as DBNull.Value .
Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net
|
|
|
|
|
Ok thanks.
Maqsood Ahmed wrote: public static DBNull GetString(string textBoxString)
Because the above mentioned function returns DBNull.Value if the string contains a null value, so it can return a string value if the variable contains something?
Thanks for all the answers you have given me, it has helped a lot.
Regards.
|
|
|
|
|
Hi,
I tried the following function, but it doesn't want to work:
//*********************************************************************
//
// CheckStringForDBNulls Static Method
//
// The CheckStringForDBNulls method checks if a string contains a value, if not it
// returns DBNull.Value, or the value of the string.
//
//*********************************************************************
public static DBNull CheckStringForDBNulls(string strCheckString)
{
if(strCheckString.Trim() != string.Empty)
return strCheckString.Trim();
else
return DBNull.Value;
}
Could you please let me know what I am doing wrong? This is used to check the parameter being added, if it contains nothing, the make the value DBNull.Value, or use the value of thr string.
Thanks
BRENDAN
|
|
|
|
|
I need to create a timeline control in C# and I'm not sure how to begin. I am new to C# (and custom control development for that matter) and I need to create this timeline ASAP.
What would be perfect is if I could quickly create a control that does the same thing as the timeline control in Windows Movie Maker. I need to be able to drag & drop movies from a collection (just like the collections in "Windows Movie Maker") into the timeline and each successive movie should be automatically placed directly after the previous one. I really like the timeline in Windows Movie Maker (also similar to the timeline in Adobe Priemier) because its easy to drop any video file into the timeline.
If anybody has any great insights on how to start (which controls to inherit from in order to get the starting functionality I need, or knows of any examples on the internet on how to create this type of control) any support would be greatly appreciated!
Thanks in Advance,
|
|
|
|
|
Hi,
I have the following piece of code.
private string strName;
if(txtName.Text.Trim() != "")
strName = txtName.Text.Trim();
Then I want to pass this variable to a constructor like:
Customer objCustomer = new Customer(strName);
Now strName may be null, or not. So if the if statement fails, then the value of strName is null? But it complains when I compile, and says that no value was set for strName when I pass it to the Customer constructor. So what I did was to define it like:
private string strName = null;
Which works fine, but I thought the default value for string is null?
Regards
|
|
|
|
|
Compiler warn you, it there is usage of uninitializated variables (i hope you write code without warnings). So if default value is null you can easily check for it - (vaiable != null).
Your code works fine because of null is valid value for object.
BTW. It is better way to write page-behind classes instead of usage of form class, it is more clean to understand and can be useful for reflection operations
|
|
|
|
|
ma se wrote:
Which works fine, but I thought the default value for string is null?
That's true only if strName is a member variable. Local variables need to be initialized explicitly.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
The compiler will error out if you don't initialize the variable before setting it. In this case it doesn't matter whether or not strName is null, you just have to set it first. Try this code bit:
<code>
private string strName = null;
if(txtName.Text.Trim() != "")
strName = txtName.Text.Trim();
</code>
A more safe and better way to do this would be:
<code>
private string strName = null;
if(txtName != null && txtName.Text.Trim().Length > 0)
strName = txtName.Text.Trim();
</code>
|
|
|
|
|
I have 2 separated solutions one for my asp.net application and the other is components solutions , in application i added a reference from one of DLLs that are generated in specific folder (such C:\Components), my problems in certain situation i have to debug the DLL with the current parameters , but i can though its a debug version, what is the avaiable techniques to do this ?
|
|
|
|
|
Did you try attaching to the ASP .NET worker process (aspnet_wp or something similar)?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|