h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Class Diagram in C#.Net



Introduction:
                        Class Diagrams are newly added in Visual Studio 2005 edition. They provide designers, architects and developers a graphical interface to manipulate methods, properties, fields, events for data structures like classes, interfaces, structure etc.
Let us now explore all the features of Class designer.
Creating Classes using Class Diagrams
Create New Project in Visual Studio 2008 called “Class Diagram”.
Add Class Diagram’s File in your Project. It is shown below.



Class Diagram name is Called “Maths.cd”.


Right Click on the Screen .Context menu will display






Click “Class” Menu in the Screen.


Add Class name “Calculation”.
You can also choose Access of Class using Access Drop down box.
Right Click on your Class File in the Class Diagram.
Click “Add” Menu
Click “Property” Menu if you want.  i.e:  first Name, secondName.

Note: Same Procedure for Method, struct, Field, Event.


Here, I create an Add Method for this Program.


Add Parameter for Method:

        Go to Class Details window.

        Add your parameter for your method.

        Two parameters assigned for Add method (firstValue, secondValue).

       Go to method property in the classdiagram file.

       Change the Value of false to true of the static property of the method.

       See below screen



 Go to your Calculation.cs file and add this code in the Add Method

   return firstValue + secondValue;
Copy and paste this code in your form_load Event
          int result = Calculation.Add(50,50);
     MessageBox.Show(result.ToString());
Result:
     100.
 Thanks for reading this article. 

Today's Quoto:
        Life is like riding a bicycle. To keep your balance, you must keep moving!
 

Focus on Next Button after Clicked Previous Button Using C#.Net

            Today , we will discuss about focus on Next Button after clicked previous button using C#.net
Declare Variable
private static bool IsBtnClicked = false;
Go To Next button Property window
Select "Tab Stop"  and Change to False
Copy and Paste this below Code in your Previous Button Click Event:
IsBtnClicked = true;
if (IsBtnClicked)
{
button2.TabStop = true;
IsBtnClicked = false;
}
else
{
button2.TabStop = false;
IsBtnClicked = false;
}

Focus on New Line in TextBox in C#.net

Today ,we will discuss about focus on New line in TextBox in C#.Net

Select Multiple Line option in the TextBox.
Call this Code in your TextBox KeyDown Event
if (e.KeyCode == Keys.Enter)
{
(textbox name).AppendText((textbox name).Text);
}

Compare DatagridviewComboBox Value with TextBox Value in DataGridview using C#.net

"Compare DatagridviewComboBox Value with TextBox Value in DataGridview using C#.net"
private void button1_Click(object sender, EventArgs e)
{
DataGridViewComboBoxColumn column1 = (DataGridViewComboBoxColumn)dataGridView1.Columns[0];
foreach (string str in column1.Items)
{
if (str == textBox1.Text)
{
MessageBox.Show("Already Exists");
break;
}
}
}

Compare Two Cell Values in Datagridview using C#.Net

private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
if (e.ColumnIndex == 2)
{
 int minValue = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["MinValue"].Value.ToString()); int maxValue = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["MaxValue"].Value.ToString()); bool chkValue = compareTwoCellValues(minValue, maxValue);
if (chkValue)
{
 dataGridView1.AllowUserToAddRows = false; dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["MaxValue"].Selected = true; chkValue = false;
}
 else
 {
 dataGridView1.AllowUserToAddRows = true; chkValue = false;
 }
}
}
bool statusofCompareValue;
bool compareTwoCellValues(int MinValue, int MaxValue)
{
 if (MinValue > MaxValue)
 {
 MessageBox.Show("Please enter greater than value"); statusofCompareValue = true;
 }
 else
 {
statusofCompareValue = false;
}
 return statusofCompareValue;
 }

Display File Name path in ComboBox using C#.Net

"Display File Name path in Combobox using C#.Net"


addParentdirectoryFile Method
private void addParentdirectoryFile(string sourcePath)
{
string[] fileNames = Directory.GetFiles(sourcePath);
foreach (string str in fileNames)
{
comboBox1.Items.Add(str);
}
}
addChildDirectFiles Method
private void addChildDirectFiles(string sourcePath)
{
foreach (string subFolders in Directory.GetDirectories(sourcePath,"*",SearchOption.AllDirectories))
{
string[] subFolderfileNames = Directory.GetFiles(subFolders);
foreach (string fname in subFolderfileNames)
{
comboBox1.Items.Add(fname);
}
}
}
Call this method where you want:
addParentdirectoryFile();
addChildDirectFiles();