|
You can .NET send message to the .NET handle (kind of / sort of like a pipeline), invoke (if one process spawned/grabbed the other one), and even use the use native win32 API's also...
|
|
|
|
|
Hello, i was having a problem on coding the button.. what i want to do is put the Button on the center of the form... can anybody help me please.. i used this code.. private void generateButton_Click(object sender, EventArgs e)
{
row = int.Parse(rowsBox.Text);
col = int.Parse(colBox.Text);
Button[,] landmine = new Button[row, col];
for (int _row = 0; _row < row; _row++) {
for (int _col = 0; _col < col; _col++) {
landmine[_row, _col] = new Button();
landmine[_row, _col].Width = 35;
landmine[_row, _col].Height = 35;
landmine[_row, _col].Left = 100 + _col * 35;
landmine[_row, _col].Top = 100 + _row * 35;
landmine[_row, _col].BackColor = Color.LightGray;
Controls.Add(landmine[_row, _col]);
}//end of for loop for columns...
}//end of for loop for row...
}
|
|
|
|
|
Hello,
Get the form width and height and set the button location.
Eg:
this.button1.Location = new System.Drawing.Point(form1.widht, form1.height);
Regards!
Charith
jayasshc
|
|
|
|
|
Hi,
There was a small issue with my example
use this way
this.button1.Location = new System.Drawing.Point(form1.widht/2, form1.height/2);
jayasshc
|
|
|
|
|
Try adding a panel to your form and adding the landmine controls into that panel. Then all you have to do is centre the panel controls. e.g.
<br />
private void generateButton_Click(object sender, EventArgs e)<br />
{<br />
int row = int.Parse(rowsBox.Text);<br />
int col = int.Parse(colBox.Text);<br />
<br />
Button[,] landmine = new Button[row, col];<br />
for (int _row = 0; _row < row; _row++)<br />
{<br />
for (int _col = 0; _col < col; _col++)<br />
{<br />
landmine[_row, _col] = new Button();<br />
landmine[_row, _col].Width = 35;<br />
landmine[_row, _col].Height = 35;<br />
landmine[_row, _col].Left = _col * 35;<br />
landmine[_row, _col].Top = _row * 35;<br />
landmine[_row, _col].BackColor = Color.LightGray;<br />
panel1.Controls.Add(landmine[_row, _col]);<br />
}
}
<br />
panel1.Size = new Size(row * 35, col * 35);<br />
Size parentSize = panel1.Parent.ClientSize;<br />
panel1.Location = new Point((int)(parentSize.Width / 2 - panel1.Size.Width / 2), (int)(parentSize.Height / 2 - panel1.Size.Height / 2));<br />
} <br />
You could also set the Anchor property on the panel to None to keep the controls centred while the form resizes.
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Sir, thank you so much.. it worked.. i never thought that it would just be it.. .. thank you so much again sir...
|
|
|
|
|
Good day my good fellows.
I am really struggeling with the following problem.
I am generating a Crystal Report from a data set using C#.
The report must consist of 2 pages.
Page 1) Is a letter conaining 1. Recipient Name
2. Issue
these two values are drawn from the dataset. The apear only once on the 1st page
Page 2) Is a summury of the Recipients' accounts with a specified service provider.
fields are Details, Acc No, Interest Rate, Instalment Amt, Balance.
Now, I cant seem to get the Account detail displayed on the 2nd page without the whole report being pulled out of preportions.
I tried using Groups and I tried using sub reports but they dont work.
Sub reports might work but it does'nt seem to work very well with the CrystalReports pagaged with Visual studio.
help would be appreciated.
|
|
|
|
|
Hey Guys,
i have a dataGridView control on my form with only one column of type string. Now i need to get all the strings out of it one by one... how would i do that cuz it cant foreach
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
for(int i = 0; i < dataGridView.Rows.Count; i++) {
Console.WriteLine(dataGridView.Rows[i][0]); }
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
Hey, thanx for the reply...
that was the logical sollution for me too, but it doesnt allow the 2nd index (the one for the column)
i tried these and they did not work
foreach (DataGridViewRow row in pollTimesDataGridView)
{
string myString = row[0];
MessageBox.Show(myString);
}
for (int i = 0; i < pollTimesDataGridView.Rows.Count; i++)
{
MessageBox.Show(pollTimesDataGridView.Rows[i][0]);
}
any ideas?
thanx justin
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
Hi,
Here is the code for foreach
DataGridView grvCompany = new ....;
foreach (DataGridViewRow row in grvCompany.Rows)
{
//
}
Thanks!
Charith
jayasshc
|
|
|
|
|
Run code, press down arrow, up arrow, down arrow.
Invalid operatoin exception occurs.
How to fix ?
Andrus.
using System;<br />
using System.Windows.Forms;<br />
using System.ComponentModel;<br />
<br />
class Supplier {<br />
public string Id { get; set; }<br />
}<br />
<br />
class Form1 : Form {<br />
[STAThread]<br />
static void Main() {<br />
Application.Run(new Form1());<br />
}<br />
<br />
public Form1() {<br />
DataGridView grid = new DataGridView();<br />
grid.EditMode = DataGridViewEditMode.EditOnEnter;<br />
ComboBoxColumn comboBoxColumn = new ComboBoxColumn();<br />
ComboBoxCell ComboBoxCell = new ComboBoxCell();<br />
comboBoxColumn.CellTemplate = ComboBoxCell;<br />
grid.Columns.Add(comboBoxColumn);<br />
BindingList<Supplier> l = new BindingList<Supplier>();<br />
l.Add(new Supplier());<br />
grid.DataSource = l;<br />
Controls.Add(grid);<br />
}<br />
<br />
class ComboBoxColumn : DataGridViewComboBoxColumn { }<br />
<br />
class ComboBoxCell : DataGridViewComboBoxCell {<br />
public override Type EditType {<br />
get {<br />
return typeof(ComboBoxEditingControl);<br />
}<br />
}<br />
<br />
}<br />
<br />
class ComboBoxEditingControl : ComboBox, IDataGridViewEditingControl {<br />
protected int rowIndex;<br />
protected DataGridView dataGridView;<br />
protected bool valueChanged = false;<br />
<br />
protected override void OnTextChanged(EventArgs e) {<br />
base.OnTextChanged(e);<br />
NotifyDataGridViewOfValueChange();<br />
}<br />
<br />
protected virtual void NotifyDataGridViewOfValueChange() {<br />
valueChanged = true;<br />
if (dataGridView != null) {<br />
dataGridView.NotifyCurrentCellDirty(true);<br />
}<br />
}<br />
<br />
public Cursor EditingPanelCursor {<br />
get {<br />
return Cursors.IBeam;<br />
}<br />
}<br />
<br />
public DataGridView EditingControlDataGridView {<br />
get {<br />
return dataGridView;<br />
}<br />
set {<br />
dataGridView = value;<br />
}<br />
}<br />
<br />
public object EditingControlFormattedValue {<br />
set {<br />
if (value.ToString() != Text) {<br />
Text = value.ToString();<br />
NotifyDataGridViewOfValueChange();<br />
}<br />
}<br />
<br />
get {<br />
return Text;<br />
}<br />
}<br />
<br />
public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts<br />
context) {<br />
return Text;<br />
}<br />
<br />
<br />
<br />
public void PrepareEditingControlForEdit(bool selectAll) { }<br />
<br />
public bool RepositionEditingControlOnValueChange {<br />
get {<br />
return false;<br />
}<br />
}<br />
<br />
public int EditingControlRowIndex {<br />
get {<br />
return rowIndex;<br />
}<br />
<br />
set {<br />
rowIndex = value;<br />
}<br />
}<br />
<br />
public void ApplyCellStyleToEditingControl(DataGridViewCellStyle<br />
dataGridViewCellStyle) {<br />
DropDownStyle = ComboBoxStyle.DropDown;<br />
}<br />
<br />
public bool EditingControlWantsInputKey(Keys keyData, bool<br />
dataGridViewWantsInputKey) {<br />
return !dataGridViewWantsInputKey;<br />
}<br />
<br />
public bool EditingControlValueChanged {<br />
<br />
get {<br />
return valueChanged;<br />
}<br />
set {<br />
valueChanged = value;<br />
}<br />
}<br />
}<br />
}
Andrus
|
|
|
|
|
If I was you, I'd think it would be easiest to get help if I posted the entire, actual error message, and only the little relevant piece of code. Otherwise, we have to guess where the error is coming from, and what it is, because no one is going to read through all that code to find where it is coming from.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
Justin,
thank you.
Exception occurs in Application.Run() method:
System.InvalidOperationException was unhandled
Message="Operation is not valid due to the current state of the object."
Source="System.Windows.Forms"
StackTrace:
at System.Windows.Forms.DataGridView.DataGridViewDataConnection.ProcessListChanged(ListChangedEventArgs e)
at System.Windows.Forms.DataGridView.DataGridViewDataConnection.currencyManager_ListChanged(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.InsertItem(Int32 index, T item)
at System.Collections.ObjectModel.Collection`1.Add(T item)
at System.ComponentModel.BindingList`1.AddNewCore()
at System.ComponentModel.BindingList`1.System.ComponentModel.IBindingList.AddNew()
at System.Windows.Forms.CurrencyManager.AddNew()
at System.Windows.Forms.DataGridView.DataGridViewDataConnection.AddNew()
at System.Windows.Forms.DataGridView.DataGridViewDataConnection.OnNewRowNeeded()
at System.Windows.Forms.DataGridView.OnRowEnter(DataGridViewCell& dataGridViewCell, Int32 columnIndex, Int32 rowIndex, Boolean canCreateNewRow, Boolean validationFailureOccurred)
at System.Windows.Forms.DataGridView.SetCurrentCellAddressCore(Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean throughMouseClick)
at System.Windows.Forms.DataGridView.ProcessDownKeyInternal(Keys keyData, Boolean& moved)
at System.Windows.Forms.DataGridView.ProcessDownKey(Keys keyData)
at System.Windows.Forms.DataGridView.ProcessDataGridViewKey(KeyEventArgs e)
at System.Windows.Forms.DataGridView.ProcessKeyPreview(Message& m)
...
This is probably caused because DataGridView does not call RemoveItem() event when it cancels edit.
You can run this code to see it.
Andrus.
Andrus
|
|
|
|
|
I am a junior software engineer..am getting so much of doubts on sql server 2000.Tell you..please solve my issue to work with it better.
Ok the matter is ,how can i insert a lot of strings in the same time to the same field ?.
for example..I want to insert 'xp','vista','mac' and a hundreds of other names again.
So how can i add those hundreds of strings with one querry.
and it should go to one and same field
help me please...
|
|
|
|
|
|
HI,
I need to append new tags to the existing xml document.
PLease review this code ,
string txt = TextBox1.Text.ToString();
XmlDocument doc= new XmlDocument();
doc.LoadXml(txt);
XmlElement el = doc.CreateElement("property1");
el.SetAttribute("name1", "C1");
el.InnerText = "This row is being appended to the end of the document.";
doc.DocumentElement.AppendChild(el);
doc.Save(txt);
This code will be helpful to create the childnode, but iam looking for appending Root node as well as childnodes.
Please help me to extend this code for Root nodes.
Note : no need to create XmlDeclaration statement becoz it will be thr for selected xml file by default.
Appreciate your precious reply.
Thanks a lot,
Anjali...
|
|
|
|
|
mayuri123 wrote: but iam looking for appending Root node
XmlElement eRoot = doc.CreateElement("Root");<br />
doc.AppendChild( eRoot);
Keep in mind you can only have one root element
led mike
|
|
|
|
|
led mike wrote: Keep in mind you can only have one root element
Only if you want it to be valid
only two letters away from being an asset
|
|
|
|
|
Hi all,
String.replace("\","\\") never work for me.I am also try use char,but still no work. Can anyone help me on this?
regards
cocoon
|
|
|
|
|
Does this work?
String.replace("\\","\\\\")
|
|
|
|
|
The backslash in a string is used as an escape character and won't get printed on its own. To print a backslash, the string would be "\\". Another example of common usage of \ would be "\n" to perform a new line.
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
String.replace(@"\",@"\\")
SkyWalker
|
|
|
|
|
Hi ,
Thanks for fast reply. Yes, string.replace("\\","\\\\") and string.replace(@"\",@"\\") are work great,thanks guy!
|
|
|
|
|
Hi,
i am currently taking part in a project at my university and making my first advanced steps in programming in C# and .NET. In my group we want to implement a sound module to manipulate the mic input. Due to our low level of experience we have several problems. Currently we can just load a wav-File into a buffer, adding a custom sample effect und play it back, all using DirectSound.
In theory, we want to be able to load the continous microphone input into a buffer to manipulate it in "real time" and then give the modified stream out of the buffer back through the speaker. I am sure there will always be a short delay, put hopefully it can not be recognized.
Most of the audio examples cover a recording of a mircrophone input into a wav-File. My intention is not to ask for the implementation of our project, but I hope you can give us some hints how we should begin and which functions are essential for our functionality.
We currently use C# with the latest .NET Framework (3.5) and DirectSound.
I am looking forward to a good excited discussion.
Sincerly,
Daniel
|
|
|
|
|