|
Hi,
I have 2 C# Projects together (web service / windows application)in one Solution in Visual Studio 2003 and I want to share some window´s project´s classes to the web service project.
The only way I´ve been able to do this, is to Create the third Project within the same solution as a ClassLibrary (DLL) and copy/paste some of the windows application´s classes to that third project.
Then I add a reference (in the web service / windows application projects) to the third Classlibrary project by doing:
References->Add Reference-Projects->*Pick the Classlibrary project*
Is there any other (more simple) way of doing this?
Thanks in advance!!
BinaryHead
P.S. I know how to share classes within the same project (just by using simple namespaces).
|
|
|
|
|
Hi!
That's exactly the way to do it. Referencing the other project directly usually won't work because you get circular dependencies.
The only way to solve these is to put common parts into a separate assembly and referencing this assembly from your other projects.
The good news is that VS takes care of distributing the common assembly to where-ever it's referenced in your project when you rebuild, so you don't have to waste a doubt on where to copy the output after building.
Regards,
mav
|
|
|
|
|
you can share a common file (a class say) at a source level between two different solutions by just adding the file (add an existing item) to the appropriate project. The default in vs would be to create a copy of the file in each project that it is added to, but if you look closely the 'open' button on the file selection dialog is actually a drop-down combo, with the last choice being 'link file'. If you use the 'Link file' choice, no copy is created, and the file becomes truly shared between the projects, just like a common header file is used in C++.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
how can i add a progress bar into a datagrid. i would like to perform some actions when an iten in the datagrid is clicked and control the progressbar accordingly. How can i do this.
|
|
|
|
|
There is a similar article
http://www.codeproject.com/cs/miscctrl/RenDataGridComboBoxColumn.asp
Hope this helps.
Live Life King Size
Alomgir Miah
|
|
|
|
|
Hello there
I am building a control where user will browse one XML file and will play with the records in that. what I have done is very simple. After browsing XML I just use Dataset.readXML to get the contents and then
dataGrid1.DataSource= Dataset;
now I want that the values should be automatically saved in the XML file when changed. how ???
Second thing after binding = I have one column in Datagrid which I shall make read only. it should keep the last Changed value. means if the name was
"ABC" and user Changed it then Column 2 should have value "ABC" and the new value in column 1 should be assigned by user.
|
|
|
|
|
This may be an easy fix. Nevertheless, I am having problems running a program on a separate machine then what it was developed on. The executable runs and is operational. However, the resolution is WAY off. The form becomes quite large. The buttons are large and they moved slightly to the right as well. I was sure that it was just the resolution on the machine that the executable was running on. That was not the case. Therefore, I am here. Seeking help from anyone that may have encountered a similar problem. Thanks in advance.
|
|
|
|
|
Is this happening on any other machine, or just some of them? IF the latter, one posibility is that the system is set to use large fonts and the controls were scaled in responce to the accesibility changes.
|
|
|
|
|
I think you hit the donkey on the rear. I will give that a try. Thanks for your help.
|
|
|
|
|
Hi There,
I'm using SQLHelper class as data access layer in a C#.NET application. The problem is that i've to give an option of restoring current database from a given backup file. But when since the current database(with which application is running) due to the connections that SQLHelper opened for database access so far cannot be replaced and the error message is received. All what needed is to clear all the active database connections to perform that restore process. Currently the procedure that i'm using is saved in Master database and it can clear any active no. of connections but the problem is that SQLHelper holds all those connections and doesn't release them immediately. So plz may i be guided on this issue to enforce SQLHelper class to release those connections immediately after use. Or if is there any other smarter solution then plz guide. I shall be highly obliged.
Regards
|
|
|
|
|
You will have to use SQL DMO to acheive this.
http://www.csharphelp.com/archives2/archive342.html
Live Life King Size
Alomgir Miah
|
|
|
|
|
Hello,
Is there a way of suppressing ColumnChanged event, when I am adding a new row like this:
Debug.WriteLine("Adding new row");<br />
DataRow rowName = this.dataset.Tables["Stages"].NewRow();<br />
this.textBoxTotalUnits.Text = totalUnits;<br />
System.DateTime dt = System.DateTime.Now;<br />
rowName["StageNumber"] = 1;<br />
rowName["NumUnits"] = Convert.ToInt32(totalUnits);<br />
rowName["MonthsToService"] = 5;<br />
rowName["RegistrationDate"] = dt; <br />
rowName["AvgAbsorptionPerMonth"] = 7;<br />
double remainder = Math.IEEERemainder(Convert.ToInt32(totalUnits), 7);<br />
if (remainder == 0) <br />
{<br />
rowName["TotalMonthsAbsorption"] = Math.Floor(Convert.ToInt32(totalUnits)/7);<br />
} <br />
else <br />
{<br />
rowName["TotalMonthsAbsorption"] = Math.Floor(Convert.ToInt32(totalUnits)/7)+1;<br />
} <br />
<br />
this.dataset.Tables["Stages"].Rows.Add(rowName);
Thank you!
|
|
|
|
|
zaboboa,
Well there is no quick and easy way to do this. However you can do this in two ways. Events on a control are hooked to your function in initialization phase through a simple += statement. before you execute your code you could un hook the event handler add the row and then hook the event handler back in. this is a rather crude way to handle this.
the other option is maintain a flag in your code. when adding the row before adding the row set the flag. check this in the columnchanged event handler. if it is set then ignore the event. after the row is added reset this flag.
Hope this helps...
Prady
|
|
|
|
|
See the example
this.dataGridTextBoxColumnExValue.TextBox.KeyPress -= new KeyPressEventHandler(this.TextBoxFloatValueKeyPress);
//Do your stuff
this.dataGridTextBoxColumnExValue.TextBox.KeyPress += new KeyPressEventHandler(this.TextBoxFloatValueKeyPress);
Live Life King Size
Alomgir Miah
|
|
|
|
|
Thank you.
That's excactly what I am doing, is to keep a flag.
|
|
|
|
|
Hello,
I have been trying to add a custom control to one of the columns in my DataGrid, but I have failed so far. What I want to do is to add my custom control (or any other standard control for that matter) to the control collection of a certain column style. When I do so, the control will not appear until I click on any of the cells, which is supposed to show the control. Is it even possible to add controls to the control collection of textbox column styles, considering what I want to do? If you have any ideas, please use my sample code below as a starting point and reply to me with a modified version of it.
Also, I am curious to know what causes this kind of weird behaviour. I would have expected the button to appear right away, but that's obviously not the case . Does anyone have extremely detailed knowledge about how and when controls are painted? I would like to know the exact chain of events that causes this behaviour and why.
Thank you for your patience, I hope you can help!! (I wont settle for a workaround )
<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
<br />
namespace WindowsApplication2<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.ComponentModel.Container components = null;<br />
<br />
DataGrid grid = new DataGrid();<br />
DataTable table;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
this.Controls.Add( this.grid );<br />
<br />
this.table = new DataTable("A_Table");<br />
this.table.Columns.Add( new DataColumn("TextColumn", typeof(string)) );<br />
this.table.Columns.Add( new DataColumn("ButtonColumn", typeof(string)) );<br />
<br />
DataSet dataSet = new DataSet();<br />
dataSet.Tables.Add( this.table );<br />
this.grid.SetDataBinding(dataSet, "A_Table");<br />
<br />
DataGridTableStyle tStyle = new DataGridTableStyle();<br />
tStyle.MappingName = "A_Table";<br />
DataGridTextBoxColumn textStyle = new DataGridTextBoxColumn();<br />
textStyle.MappingName = "TextColumn";<br />
textStyle.HeaderText= table.Columns[0].Caption;<br />
textStyle.Width = 200;<br />
textStyle.ReadOnly = true;<br />
tStyle.GridColumnStyles.Add(textStyle);<br />
<br />
textStyle = new DataGridTextBoxColumn();<br />
textStyle.MappingName = "ButtonColumn";<br />
textStyle.HeaderText= table.Columns[1].Caption;<br />
textStyle.Width = 80;<br />
textStyle.ReadOnly = true;<br />
<br />
Button b = new Button();<br />
b.Text = "OK";<br />
b.Dock = DockStyle.Fill;<br />
textStyle.TextBox.Controls.Add( b );<br />
tStyle.GridColumnStyles.Add(textStyle);<br />
<br />
tStyle.PreferredRowHeight = 20;<br />
this.grid.TableStyles.Add(tStyle);<br />
this.grid.Location = new Point(10, 10);<br />
this.grid.Size = new Size(400, 100);<br />
<br />
this.Width = 420;<br />
this.Height = 200;<br />
<br />
DataRow row = table.NewRow();<br />
row[0] = "There should be a button to the right";<br />
row[1] = "";<br />
table.Rows.Add(row);<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
private void InitializeComponent()<br />
{<br />
this.components = new System.ComponentModel.Container();<br />
this.Size = new System.Drawing.Size(300,300);<br />
this.Text = "Form1";<br />
}<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
}<br />
}<br />
|
|
|
|
|
i'm working on window application.
I have a usercontrol which contains a datagrid and two buttons for save and close.
When the code is being executed, i use tab key to go from one control to another. However, when i'm in the datagrid control, i enter some details and then press the tab key, it doesn't go to the save button. It just keeps going in the datagrid. It doesn't come out. I've set the tab index for the controls, but they dont seem to have any effect once it goes in the datagrid control...
plz tell me wot to do..
any help is appreciated..
thanks
|
|
|
|
|
You need to subclass DataGrid control, DataGridTextBox control.
In the Derived classes do the following
public override bool PreProcessMessage(ref Message msg)
{
Keys keyCode = (Keys)(int) msg.WParam & Keys.KeyCode;
switch (keyCode)
{
case Keys.Tab:
return true;
default:
break;
}
return base.PreProcessMessage(ref msg);
}
Live Life King Size
Alomgir Miah
|
|
|
|
|
I am trying to get the maximum value in a colum of a data table the table layout is as follows:
dt = new DataTable("Contact");<br />
dc = new DataColumn("Contact_Number",System.Type.GetType("System.Int32"));<br />
dt.Columns.Add(dc);<br />
dc = new DataColumn("JobTitle",System.Type.GetType("System.String"));<br />
dt.Columns.Add(dc);<br />
dc = new DataColumn("CompanyName",System.Type.GetType("System.String"));<br />
dt.Columns.Add(dc);<br />
dc = new DataColumn("WebPage",System.Type.GetType("System.String"));<br />
dt.Columns.Add(dc);<br />
dc = new DataColumn("Department",System.Type.GetType("System.String"));<br />
dt.Columns.Add(dc);<br />
dc = new DataColumn("Office",System.Type.GetType("System.String"));<br />
dt.Columns.Add(dc);<br />
dc = new DataColumn("Profession",System.Type.GetType("System.String"));<br />
dt.Columns.Add(dc);<br />
dc = new DataColumn("ManagersName",System.Type.GetType("System.String"));<br />
dt.Columns.Add(dc);<br />
dc = new DataColumn("PAName",System.Type.GetType("System.String"));<br />
dt.Columns.Add(dc);<br />
dc = new DataColumn("Catagory",System.Type.GetType("System.String"));<br />
dt.Columns.Add(dc);<br />
dc = new DataColumn("AddressStreet",System.Type.GetType("System.String"));<br />
dt.Columns.Add(dc);<br />
dc = new DataColumn("AddressCity",System.Type.GetType("System.String"));<br />
dt.Columns.Add(dc);<br />
dc = new DataColumn("AddressState",System.Type.GetType("System.String"));<br />
dt.Columns.Add(dc);<br />
dc = new DataColumn("AddressZip",System.Type.GetType("System.String"));<br />
dt.Columns.Add(dc);<br />
dc = new DataColumn("AddressRegion",System.Type.GetType("System.String"));<br />
dt.Columns.Add(dc);<br />
<br />
dt.PrimaryKey = new DataColumn[]{dt.Columns["Contact_Number"]};<br />
this.contactsDataSet.Tables.Add(dt);
I am using the compute function but I get an error saying type cast invalid
int nextNumber<br />
=(int)contactsDataSet.Tables["Contact"].Compute("MAX(Contact_Number)","");
I need to find the max value in order to use it as a primary key,
Any suggestions would be great...
|
|
|
|
|
hi all,
I need to obtain All users and their passwords of SQL Server 2000.
Can I do that?
thanks in advance.
|
|
|
|
|
Usernames, yes. Passwords, no.
Think about the HUGE security violation that would be if that function call got into the wrong hands.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi to all,
how can i loop through all the items of a combobox and get the index, value and text of each item
best regards and thanks in advance
fady
|
|
|
|
|
Hi fady,
The combobox has a property called Items. This is a collection so you could use something like this:
foreach(String str in combobox.Items)
{
...
}
Prady
|
|
|
|
|
The combobox has an Items collection. Each item in the collection has properties for the text and value.
---
b { font-weight: normal; }
|
|
|
|
|
thanks to your reply,
i tried to use the items but i doesn't work because my combo is binded with a dataset
comboBox1.DisplayMember = "LIBL";
comboBox1.ValueMember = "ID";
comboBox1.DataSource = oDs.Tables[0];
the dataset is filled through a stored procedure
best regards,
fady
|
|
|
|