|
Hello
Your title was about assigning values. This means True or false valus to the cells. This is done simply by changing the DataGridViewCheckBoxCell.Value property to either true or false.
OTOH in your post you said you want to change the index!! this is considered more with rows not columns. If you want to change the display index of a row -Move it up or down in the grid-:
DataGridViewRow MyTempRow = MyDataGridView.Rows[OldIndex];
MyDataGridView.Rows.RemoveAt(OldIndex);
MyDataGridView.Rows.Insert(NewIndex, MyTempRow);
PS.I used OldIndex/NewIndex naming conventions just for the sake of clarity. If you want to get the first selected row use MyDataGridView.SelectedRows[0], provided that you check it is not null first.
Regards
|
|
|
|
|
1] Is there any method of load form2 from form1?
2] Is case of resize form1 ,when a form1 is loaded textbox size is equal to form1 size & when i hide the status bar this resize statement is work but at loaded time its not work what is reasion behind it?
e.g.
//above code is not work properly
private void Form1_Load(object sender, EventArgs e)
{
//toolStripStatusLabel1.Text = "© 2006,Microsoft Corporation,All Rights Reserved";
textBox1.Font = new Font("Arial",16,FontStyle.Bold);
textBox1.Size = new System.Drawing.Size((this.Width - 10), (this.Height - 80));
}
//above code is work properly
private void statusBarToolStripMenuItem_Click(object sender, EventArgs e)
{
if (statusflag == false)
{
statusBarToolStripMenuItem.Checked = true;
statusStrip1.Visible = true;
statusflag = true;
textBox1.Size = new System.Drawing.Size((this.Width - 10), (this.Height - 80));
}
else
{
statusBarToolStripMenuItem.Checked = false;
statusStrip1.Visible = false;
statusflag = false;
textBox1.Size = new System.Drawing.Size((this.Width - 10), (this.Height - 60));
}
}
desert_rose
|
|
|
|
|
Stateless wrote: 1] Is there any method of load form2 from form1?
A form is just a class. You just instantiate the class and call the apropriate methods on it.
MyForm frm = new MyForm();
frm.Show();
Stateless wrote: Is case of resize form1 ,when a form1 is loaded textbox size is equal to form1 size & when i hide the status bar this resize statement is work but at loaded time its not work what is reasion behind it?
Why don't you just use the Dock[^] property on the text box to get it to fill the window by setting it to DockStyle.Fill . Then you don't have to worry about that because it will resize itself automatically.
Stateless wrote: //toolStripStatusLabel1.Text = "© 2006,Microsoft Corporation,All Rights Reserved";
I'm really curious about that line. Why were you thinking of assigning the copyright of your applicaiton to Microsoft?
|
|
|
|
|
Is there any method which will compare two strings and returns the difference between both strings ?
eg. string str1 = "123";
string str2 = "12345";
in this case result should be "45".
|
|
|
|
|
Hi,
You can use -
string result = str2.Replace(str1,"")
<marquee>"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
Anant Y. Kulkarni
|
|
|
|
|
i'm trying to connect to the SQL Server. the problem is that im not connecting to an existing database. i'm trying to connect to the server so that i can execute queries and create a database programmatically. so if any one can help then i'll be waiting.
i'm attaching the connection string that i'm using
ConnectionString="Integrated Security=SSPI;"+"Initial catalog=;"+"Data Source=localhost";
i've not used Username and password 'cause im not using any server authenticaion. I'm using the windows authentication. should i include the username and password of the windows authentication??
Saira
|
|
|
|
|
As far as I know, you cannot connect to SQL Server without connecting to any database. So try to fill the Initial catalog (for example, master database).
If that does not help, please post the error message you receive.
|
|
|
|
|
Hello
Chopeen is right! You should connect to master database if you want to connect directly to the database, or any other INFORMATION_SCHEMA if you want to get info about existing databases. Yet, I must remind you not to edit/add/remove anything to the master database or any other default database. This is considered dangerous and inappropriate.
Regards
|
|
|
|
|
Hi
You can connect to a SQLServer without specifing any Database.Just skip the Initial Catalog part and every thing will be fine.
If you are using windows authentication you should not include user name and password(That's why we use windows authentication )
Best regards
Nima
|
|
|
|
|
well nima i've already tried this approach but it still doesn't work
could this problem be solved after i use MSDE? i'm not using it right now.
anyway thanks for your reply.
regards
saira
|
|
|
|
|
Hi
You should omit the whole part (there should be no Initial Catalog in your connection string) something like :
<br />
string connectionString="Data Source=.;user=sa;pwd=sa";<br />
That's it.
I'm not sure about MSDE I've used this on SQL Server 2000 and It's working fine (but I didn't check it using windows authentication)
Try connecting to your server using Visual Studio Server Exlorer and don't enter any database then take a look at its connection string.(It seems that using this way a connection to default database is established)
|
|
|
|
|
hello
i've solved the problem in another way.
string ConnectionString="Integrated Security=SSPI;"+"Initial Catalog=;"+"Data Source=.;";
thanks for your efforts.
however there is another problem.
an error occurs when i run the create database query that is
string sql="CREATE DATABASE my_db ON PRIMARY"
+"(Name=test_data, filename='C\\mysql\\mydb_data.mdf', size=3"
+"maxsize=5, filegrowth=10%)log on"
+"(name=mydb_log, filename='C\\mysql\\mydb_log.ldf', size=3"
+"maxsize=20, filegrowth=1)";
the error is
"invalid use of the option maxsize in the CREATE/ALTER DATABASE statement"
can u tell me what i'm doing wrong with the query??
SAIRA
|
|
|
|
|
what is the most important factor to consider when overloading and overriding in c#?
|
|
|
|
|
When overloading methods, one thing to keep in mind is consistency of the API.
For example, suppose we have a method DoSomething() that ultimately requires an integer parameter and, optionally, string and boolean parameters. One way we could do this is the following:
void DoSomething(int required1);
void DoSomething(string option1, int required1);
void DoSomething(bool option2, string option1, int required1);
While this technically works, it's not a consistent API. How often are users going to have to consult their documentation to remember the order in which parameters are expected? Even worse, imagine that your optional parameters are of the same type. How easy would it be then to accidentally swap arguments passed to the method? Yes, Intellisense helps, but it's not a substitute for a simple API and, besides, not everyone uses Visual Studio.
Consistency further applies to the default values of those optional parameters. In general, "missing" parameters should have the same default value in each overloaded method.
When overriding methods, an important thing to keep in mind is maintaining the semantics of the base class method. That is, when a base class marks a method as virtual it expects that method to behave within certain constraints, despite the fact that the derived class can theoretically do whatever it likes within that method. For example, in a file stream hierarchy it might be that the ReadByte() method throw an exception if called before the Open() method. For a Windows Forms control it might be that the overridden OnClicked() method in the derived class must call the base class method (in order for the Clicked event to be fired).
For the developer of the API, maintaining semantics means documenting, in detail, the expectations of derived classes with respect to overriding methods. For the user of the API, it means ensuring derived classes meet those expectations.
-Phil
|
|
|
|
|
Stuck on your test?
---
b { font-weight: normal; }
|
|
|
|
|
Can somebody translate this vb.net code to its c# equivalent.
Public Class ColorRange
Private _high As Color = Nothing
Private _low As Color = Nothing
Public Property Low() As Color
Get
Return _low
End Get
Set(ByVal Value As Color)
_low = Value
End Set
End Property
Public Property High() As Color
Get
Return _high
End Get
Set(ByVal Value As Color)
_high = Value
End Set
End Property
Public Sub New()
End Sub
Public Sub New(ByVal low As Color, ByVal high As Color)
_low = low
_high = high
End Sub
Public Shadows Function ToString() As String
Return String.Format("{0}, {1}", _low, _high)
End Function
End Class
|
|
|
|
|
|
|
I've never worked with VB.NET but after a quick glance at the code I think I could easily translate this within a few minutes. So why don't you feel able to do this? Don't be that lazy!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
public class ColorRange<br />
{<br />
private Color _high = Color.Empty;<br />
private Color _low = Color.Empty;<br />
<br />
public Color Low<br />
{<br />
get { return low; }<br />
set { _low = value; }<br />
}<br />
<br />
public Color High<br />
{<br />
get { return high; }<br />
set { _high = value; }<br />
}<br />
<br />
public void New()<br />
{<br />
}<br />
<br />
public void New(Color low, Color high)<br />
{<br />
_low = low;<br />
_high = high;<br />
}<br />
<br />
public override string ToString()<br />
{<br />
return String.Formt("{0},{1}",_low,_high);<br />
}<br />
}
By the way I don't even know VB but figured the C# code out easily. So you could do it. Don't be lazy and give a try next time
.:: Something is Wrong ::.
|
|
|
|
|
thanks guys. I just started using c# from vb6. I have tried to convert it already. i just want to double check it if what i have done was right
thanks
|
|
|
|
|
Well, i have created a localized version of the well known "DescriptionAttribute" attribute that derived from System.ComponentModel.DescriptionAttribue. This attribute loads the description from the resource file (you may see the SRDescriptionAttribute code in Reflector). However, when i switch a language at runtime - the old description still are shown and only descriptions that i access for the first time use the new language.
Unfortunately the "public override string Description" property is not even executed when an already loaded description is accessed again.
Any solution about how to make the system get the description again BUT NOT from the cache?
Thanks in advanced, ilan!
|
|
|
|
|
I have an app that launches another app. I dont want to return out of my function until the second app has exited. So Im using a while loop. But the first application needs repainting if you move the second app around on the screen. When I call invalidate in each pass it cleans up the garbage but does not draw controls. I see place holders of where buttons and other controls should be.
<br />
ProcessStartInfo startInfo = new ProcessStartInfo();<br />
startInfo.FileName = "InstallIDS.exe";<br />
Process process = Process.Start(startInfo);<br />
<br />
while (!process.HasExited)<br />
{<br />
Thread.Sleep(500);<br />
this.Invalidate(true);<br />
}<br />
|
|
|
|
|
You need to start the second process within a seperate thread for the first to remain responsive. I would question why you need to design it this way though. Are there other actions taht the user can be doing while the second process is running? Perhaps starting the second process in a hidden window would work for you.
only two letters away from being an asset
|
|
|
|
|
Thanks for the reply. I dont want the user to interact with the first process while the second process is running. I have a function that disables all the controls. So I think I will use that with a new thread.
I was hoping to let the parent form look responsive even though they couldnt do anything until the 2nd process was done. Its and application that launches installers and it also can delete files.. so I dont want them clicking on a button that could delete parts of something that their currently installing..
|
|
|
|