|
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
|
|
|
|
|
When you bind the data, the Items collection is populated. Then it doesn't matter where the data came from.
---
b { font-weight: normal; }
|
|
|
|
|
Could someone please give me an example in c# on capturing the right click and paste mouse events from any forms/applications. I can capture/monitor this using the keyboard but cannot do so when using mouse cut/copy and paste. Need help please.
I looked at the Globalhooksdemo (project in code project) in c# but only helped me on keyboard cut/copy and paste.
Thanks in advance
|
|
|
|
|
Hi,
I'm quite new to c# and windows.forms, so these are probably very basic questions
The first one is: what's the .net equivalent of ddx in mfc? Meaning, how do I associate the values of textboxes and checkboxes etc on forms with members of that forms? I've found ControlBindingsCollection and friends but that seems to be only for binding to databases, I want to bind to normal variables.
Secondly, in my dialog I have the following:
|---| |---|
| A | XXX | B |
|---| |---|
where the two squares A and B are list boxes and the XXX is a button. Now what I want is when the dialog is resized that the button stays the same size and that the two listboxes take up the rest of the space, so that the distance between the right of A and the left of the button stays the same, and the distance between the left of B and the right of the button stays the same as well. I cannot simply set the 'Anchor' property of A and B to 'Left,Top,Right' because that will make them overlap each other, which in turn is caused by the fact that the Anchor is relative to the parent container which is the dialog in this case. How do I do this? (Apart from overriding the dialog's OnSize and positioning everything manually).
cheers,
roel
|
|
|
|
|
Hi Roel,
First you have a much better option in c# than the one offered by MFC through the ddx functions. c# or .net controls on your form are true objects and not wrappers as in case of the of MFC. You could directly access the value of the control so in a sence there is no real need to have another variable in the form to store it. You could do something like TextBox.Text to access the value any time you want. However if you still wanted the MFC like functionality then you could probably hook the form validate event and code the actual transfer of data from control to variable manually. Why have this over head when you can access the values directly?
For the second problem you cannot do this through setting properties. You have to do this programatically.
Cheers,
Prady
|
|
|
|
|
Hello Pradyumna,
Thank you for your explanation. The reason I wanted to save to another variable was first because I thought that the controls would not be available anymore once the dialog is closed, and secondly because I'd like to encapsulate the type of control (if I decide to change a textbox with a combobox I'd have to go around around change calls to .Text with calls to .SelectedText). But I've found another way to encapsulate the functionality that I require in my dialog, so for now this problem is not relevant to me any more - but still, it's good to know for the future that there is no equivalent to ddx and that I'll have to save data manually.
As for the second part, that's too bad, I thought that with windows forms we'd have layout managers that would be just as powerful as those in eg Java's AWT or in the GTK toolkit. Looks like I was wrong
Thanks for your time!
cheers,
roel
|
|
|
|
|
Roel,
The version 2.0 for the .net framework has the layout mangers in the forms. So may be you can wait for that.
Prady
|
|
|
|