|
Perhaps this question would be better in .NET Framework [^]-forum.
However, have a look at Reporting Services included in .Net Framework.
The need to optimize rises from a bad design
|
|
|
|
|
My code creates textboxes based on data from a file. I need to be able to retreive the text from each dynamically-created textbox. By the way, each textbox is contained in a splitcontainer control (spc_Questions).
Here is the code that creates each textbox:
for (cntr = 0; cntr <; NumQ; cntr++)<br />
{<br />
input = sr.ReadLine(); <br />
newTextBox = new System.Windows.Forms.TextBox();<br />
<br />
newTextBox.Size = new Size(25, newTextBox.Size.Height);<br />
newTextBox.MaxLength = 1;<br />
newTextBox.CharacterCasing = CharacterCasing.Upper;<br />
newTextBox.TabStop = true;<br />
newTextBox.TabIndex = cntr;<br />
<br />
newTextBox.Location = new Point(spc_Questions.Panel1.Right - newTextBox.Size.Width - 10,<br />
vHeight);<br />
<br />
newTextBox.Tag = cntr.ToString();<br />
<br />
newTextBox.Show();<br />
<br />
spc_Questions.Panel1.Controls.Add(newTextBox);<br />
<br />
<br />
<br />
}
Any help would be appreciated.
|
|
|
|
|
danielhasdibs wrote: Any help would be appreciated.
Im sure it would be, but you forgot to ask a question!
|
|
|
|
|
|
you need to set the TabIndex Property
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
It's set after I create the text box.
newTextBox.TabIndex = cntr;
I've been trying to use the SelectNextControl() method to get to each textbox control, but it keeps selecting the splitcontainer instead of the textboxes.
|
|
|
|
|
what are you using passing in the first parameter in SelectNextControl()?
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Here's a sample of the SelectNextControl() method I used.
<br />
string[] textFromControl = new string[10];<br />
Control nextControl = new Control();<br />
<br />
spc_Questions.Focus(); <br />
<br />
<br />
for (cntr = 0; cntr <; NumControls; cntr++)<br />
{<br />
<br />
this.SelectNextControl(nextControl, true, true, true, true);<br />
nextControl = this.ActiveControl;<br />
nextControl.Focus();<br />
textFromControl[cntr] = nextControl.Text;<br />
}
|
|
|
|
|
Please Try this Code , it's about buttons Control , but it think you will understand my idea ......
public partial class Form1 : Form<br />
{<br />
<br />
public Button sb;<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
<br />
for (int x = 0; x < 10; x++)<br />
{<br />
sb = new Button();<br />
sb.Size = new Size(17, 17);<br />
sb.Location = new Point(x * 17, 10);<br />
sb.Tag = (x).ToString();<br />
sb.Visible = true;<br />
sb.Click += new EventHandler(sb_Click);<br />
Controls.Add(sb);<br />
<br />
}<br />
<br />
this.Size = new Size(176, (12 * 17) + 7);<br />
}<br />
<br />
<br />
private void sb_Click(object sender, System.EventArgs e)<br />
{<br />
Button sb = sender as Button;<br />
this.Text = sb.Tag.ToString();<br />
<br />
}
I know nothing , I know nothing ...
|
|
|
|
|
Thank you! Below is how I implemented it for anyone who needs it (this is in a splitcontainer -- spc_Questions):
for (cntr = 0; cntr <; NumControls; cntr++)<br />
{<br />
newTextBox = new System.Windows.Forms.TextBox();<br />
<br />
newTextBox.Size = new Size(25, newTextBox.Size.Height);<br />
<br />
newTextBox.Location = new Point(spc_Questions.Panel1.Right - newTextBox.Size.Width - 10,<br />
cntr * setHeight);<br />
<br />
newTextBox.Tag = cntr.ToString();<br />
<br />
newTextBox.TextChanged += new EventHandler(newTextBox_TextChanged); <br />
<br />
newTextBox.Show();<br />
<br />
spc_Questions.Panel1.Controls.Add(newTextBox); <br />
<br />
} <br />
<br />
void newTextBox_TextChanged(object sender, EventArgs e)<br />
{<br />
TextBox Text = sender as TextBox;<br />
ControlTexts[int.Parse(Text.Tag.ToString())] = Text.Text;<br />
}
Thank you, again!
|
|
|
|
|
Hi
I am writing a Windows application in C# that uses a Word Form template as the basis for a report. Creating the report is not a problem but I would like to temporarily change the directory that the user saves the report to.
Many Thanks
|
|
|
|
|
I don't think I could understand what you are looking for, but is this helpful?
string outputPath = @"C:\Windows\Temp";
System.IO.Directory.SetCurrentDirectory(outputPath);
Always keep the Murphy Rules in mind!
|
|
|
|
|
Hi selcuks.
Thanks for that. I've just tried it but it doesn't work. What the application does is fire up Word, creates a new document based on the template and then populates the form fields with data. The user is then presented with the document for proof reading. At this stage, the user can save the document but I would like to point them to a specific directory, as it is buried deep within our network, but leave their default directory as it is (it is a multi user app). Hope this clarifies wht I am trying to achieve.
|
|
|
|
|
Hi,
.NET 2 VS 2005
I have a panel on a winform, at runtime controls are loaded and removed using something like:
mainPanel.Controls.Clear();
mainPanel.Controls.Add(NewControl);
NewControl is a custom control that makes async calls to a web service. One example is the login screen, first time it works fine - if a user logs out the LoginControl is re displayed in the panel. The problem is that when the control is loaded for a second time, in the call back procedure if you try to reference the controls parent it is always returned as null.
When I make the async call to the web service the parent is fine. When I reference the parent in the call back procedure when the control is first loaded it is fine - however if i remove and re add the control, the parent is null in the call back procedure.
Can anyone shed any light on this?
Ive tried sending a parameter to the constructor of the control and set the parent there but this makes no difference.
Thanks,
Chas
|
|
|
|
|
If you use events that are registered on this control, you should remove them when control is removed and then re-register to the new control. Otherwise your eventhandlers listen to the removed control whose parent is null since it's removed from the panel.
Hope this helps,
Mika
The need to optimize rises from a bad design
|
|
|
|
|
Hi all,
Wel the title says it all...
I have a datagridview with a dataset as Datasource, having a few textcolumns and an imagecolumn.
When I click on the columnheader of a textcolumn the sorting happens but all my rows are back at the initial height and all the images are gone from the imagecolumn... strange behaviour,
public partial class Form1 : Form
{
private DataSet Dataset1;
private FileDialog FileDialog1;
private StringCollection rows ;
public Form1()
{
InitializeComponent();
Dataset1 = new DataSet();
Dataset1.ReadXml(@"..\..\Current.xml");
dataGridView1.DataSource = Dataset1;
dataGridView1.DataMember = "item";
this.FormClosing += new FormClosingEventHandler(FormClosing1);
this.Activated += new EventHandler(FrmActive);
FileDialog1 = new OpenFileDialog();
StringCollection cols = new StringCollection();
cols = Properties.Settings.Default.DataGridViewFormColumns;
for (int i = 0; i < cols.Count; ++i)
{
string[] array = cols[i].Split(',');
this.dataGridView1.Columns[i].DisplayIndex = Int16.Parse(array[0]);
this.dataGridView1.Columns[i].Width = Int16.Parse(array[1]);
this.dataGridView1.Columns[i].Visible = bool.Parse(array[2]);
}
}
private void FrmActive(object sender, EventArgs e)
{
SetPics();
this.Activated -= new EventHandler(FrmActive);
this.dataGridView1.Rows[0].Height = 100;
rows = new StringCollection();
rows = Properties.Settings.Default.DataGridViewFormRows;
for (int i = 0; i < rows.Count; ++i)
{
this.dataGridView1.Rows[i].Height = Convert.ToInt16(rows[i]);
}
}
private void FormClosing1(object sender, EventArgs e)
{
Dataset1.WriteXml(@"..\..\Current.xml");
StringCollection stringCollection = new StringCollection();
foreach (DataGridViewColumn column in this.dataGridView1.Columns)
{
stringCollection.Add(string.Format("{0},{1},{2}",column.DisplayIndex,column.Width,column.Visible));
}
Properties.Settings.Default.DataGridViewFormColumns = stringCollection;
Properties.Settings.Default.Save();
stringCollection = new StringCollection();
foreach (DataGridViewRow row in this.dataGridView1.Rows)
{
stringCollection.Add(Convert.ToString(row.Height));
}
Properties.Settings.Default.DataGridViewFormRows = stringCollection;
Properties.Settings.Default.Save();
}
private void SetPics()
{
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
string ImagePath = Convert.ToString(dataGridView1.Rows[i].Cells["Picture_Path"].Value);
System.Drawing.Bitmap Image1 = new System.Drawing.Bitmap(ImagePath);
dataGridView1.Rows[i].Cells["Picture"].Value = Image1;
}
}
All this actualy works great, only when i sort a column , row.heigth and images are gone ??
ps: I tested the datagridview.Sort() method which has the same behaviour ....
Thanks in advance,
Steven
modified on Tuesday, September 23, 2008 9:56 AM
|
|
|
|
|
workround:
If I sort from code I have a work round to add the images again after DatagridView.Sort() but if a user sorts by clicking then I need a event like 'AfterSort' or something which doesn't seem to exist ...
...
°°°°°°°°°°°°°°°°°°°°°°°
-- Inter Access Belgium --
|
|
|
|
|
Hello,
I am working on using a COM from C++ in new C# code. I have connected and I can get access to the member functions. The problem that I am having is that one of the member functions takes a STRUCT as an input and it outputs an array of STRUCT. And in the STRUCT there are some char arrays. So when I run the C# code I get an error message "Specified array was not of the expected type."
I'll put in a bit of the code that I am converting:
C++
-----------------
interface IHangerAssignment2 : public IUnknown
{
virtual HRESULT STDMETHODCALLTYPE Analyze(const HangerIn2& rIn, HangerOut2* pOut, int nOut, int& nResults) = 0;
};
where HangerIn2 and HangerOut2 are structs that inherit from other structs. HangerOut2 inherits from a struct that contains 2 char arrays. HangerOut2 also contains an array or char arrays.
in C#
---------------
I rewrote HangerIn2
public struct HangerIn2
{
public HangerIn hangerIn; //I just added the HangerIn struct as a member
// New USP2 properties
public double kingWidth;
public double kingHeight;
public double []bearingLength;
public bool concealedFlange;
};
I did the same for HangerOut2 which contains several arrays.
The converted code in C#
public interface IHangerAssignment
{
void Analyze(HangerIn2 hgrIn, ref HangerOut2[] hgrOut, int maxOutput, ref int nResults);
}
When this function is called, that is when I get the error "Specified array was not of the expected type."
I did notice that when stepping through the debugger that the members are always listed in alphabetical order.
|
|
|
|
|
LeonardLay wrote: in C#
---------------
I rewrote HangerIn2
public struct HangerIn2
{
public HangerIn hangerIn; //I just added the HangerIn struct as a member
// New USP2 properties
public double kingWidth;
public double kingHeight;
public double []bearingLength;
public bool concealedFlange;
};
Look, without knowing what both structs looked like in C++, I haven't a hope in heck of helping you that much, though I think that
void Analyze(HangerIn2 hgrIn, ref HangerOut2[] hgrOut, int maxOutput, ref int nResults);
should be
void Analyze(ref HangerIn2 hgrIn, HangerOut2[] hgrOut, int maxOutput, ref int nResults);
|
|
|
|
|
Hi,
I use the following wmi call on an 32 bit xp pro machine.
What is the equivalent but for a 64 bit windows server machine please?
ManagementScope myScope = new ManagementScope(myServerName + "\\root\\cimv2", options);
SelectQuery oQuery = new SelectQuery("SELECT * FROM WIN32_Printer");
ManagementObjectSearcher oResults = new ManagementObjectSearcher(myScope, oQuery);
Thanks
|
|
|
|
|
ManagementScope myScope = new ManagementScope(myServerName + "\\root\\cimv2", options);
SelectQuery oQuery = new SelectQuery("SELECT * FROM WIN64_Printer");
ManagementObjectSearcher oResults = new ManagementObjectSearcher(myScope, oQuery);
Isn't it obvious?
|
|
|
|
|
Hi,
I still get access is denied.
Please note that using this code under a 32 bit machines runs fine.
I have also made sure that I do have admin rights on the 64 bit machine.
Any thoughts please?
|
|
|
|
|
Didn't you notice joke icon? It was a joke!
I think the same code should run on 64bit as on 32bit. If you are getting an error you should post it. It can be a permission issue. You can use WMICodeCreator[^] to quickly create WMI code.
Hope it helps.
|
|
|
|
|
Hi,
It seems that every 32 bit machines works fine under this code but not any of the 64 bit machines.
Question:
How can this code under 64 bit machine when the select query is looking at win32 ?
The error I get on a 64 bit remote machine is :
Connection error (username or password might be incorrect: Access is denied.)
Note that this is the admin user login that I am using and all the machines seem fine except the 64 bit rmote machines.
Any thoughts please?
Thanks
|
|
|
|
|
There is no "64-bit version".
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|