|
thanks man
i did as i wished with your help and codes
really thank u so much )
|
|
|
|
|
It always amazes me that people try to write the most tortuous logic to communicate between two disparate items in an application when there are mechanisms built into the framework that allow you to do this with ease. Consider the problem if you want to do this with a modeless form; you want to one form to be able to respond to something that happened in another form; can you think of a mechanism that allows you to communicate in this fashion? I am, of course, talking about using events here.
Now, in your case, there is an even simpler way to achieve this. When you create an instance of Form2 (that's not a good name by the way, your naming convention should always indicate the intent of the item you are naming), you then display it using ShowDialog. This means that processing in Form1 halts until Form2 returns control to it - this, of course, means that you have access to the properties and methods inside Form2 until you Dispose of it. What you should do, in Form2, is create public properties that expose the values inside the textboxes and, once control has been returned to Form1, you should then take the values from it. Here's one way to code it:
private void btnRehber_Click(object sender, EventArgs e)
{
using (Form2 rhbForm = new Form2())
{
rhbForm.txtYetkili_isim.Text = txtYetkili_adi.Text;
if (rhbForm.ShowDialog() == DialogResult.OK)
{
txtGsm1.Text = rhbForm.Gsm1;
txtGsm2.Text = rhbForm.Gsm2;
frmFirma.txtNumara.Text = rhbForm.Numara;
}
}
} Then, in Form2, I'd create Gsm1, Gsm2 and Numara as public (or internal) readonly properties which simply wrap access to the relevant textboxes.
|
|
|
|
|
hey friend i did changed my form names as u suggested... thanks for your suggestion..
|
|
|
|
|
|
Got to agree with Pete here. Simple, elegant solutions will always work better than convoluted logic.
|
|
|
|
|
I agree this is the proper way of communicating between 2 forms.
I would also add that you could overload the constructor of the form to pass in a value.
And, you only need to dispose a form if you use ShowDialog[^].
"Make everything as simple as possible, but not simpler." - Albert Einstein Jason Henderson
|
|
|
|
|
hi... instead of using "txtGsm1.Text" better u declare a property in form2 . Then using that property u can do this.
|
|
|
|
|
i have a *.dll file contains a resource file, i want to add an new entry to the resource , so i get the resource file and add the entry. and using resgen created the *.resources file. then using al.exe tried to embed it to the dll, but then the dll is not loaded , it says the dll is corrupted.
al /t:lib /embed:s.resx,my.S.resx /culture:en /out:my.S.Resources.dll
any idea why this happens.
i used this article..NET - Localization using Resource file[^]
thanx in advance
|
|
|
|
|
Please understand, I'm asking this seriously, not to be a prick...
Why would you be creating all this by command line. You could use the Studio Express IDE to create everything you need and still compile the project from the command line. Am I wrong on this, or just confused?
|
|
|
|
|
Hi All,
I have an interesting issue writing strings to the user settings, i.e. [project].Properties.Settings.Default.[property]. Everything goes smoothly unless I try to write a single space as a string. It appears in the file as:
<setting name="someString" serializeAs="String">
<value>
</value>
</setting>
On the next load, it reads as a few unprintable chars and a lot of spaces. But other strings work fine. I'm not quite sure what I have wrong since it works with other strings
Any help is appreciated, thanks!
-Chris
|
|
|
|
|
If you have trim white space turned on in your xml reader, it will read the <value> as null/empty. Try putting the <value> </value> on the same line with a space in between them.
.45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
|
|
|
|
|
I've worked with a few old xml parsers that always trimmed each line, in order to make blank spaces work I used an ALT 255 or the 255th ascii character, which appears to be blank but is a completely different character, and then did a transformation on read. Be very careful with this though because it can be an insane pane to debug when you don't know it's an ALT 255 rather than a regular space.
|
|
|
|
|
Very interesting, thanks for the tips! I think I'll do something like Kevin mentioned, that should get it working. Thanks again! -Chris
|
|
|
|
|
If you're going to change the data anyway, it might be easier to just bracket the value... Instead of storing just the space, store it as
<value>[ ]</value>
|
|
|
|
|
How are you writing them? A text editor?
Have you tried or  
modified on Tuesday, October 12, 2010 11:31 PM
|
|
|
|
|
I'm using a DataGridView to display dynamically changing data. The first column contains a row description, two more columns contain data values. The rows are added by the following code:
foreach (DataRow symr in symdt.Rows)
{
dataGridView1.Rows.Add();
int RowIndex = dataGridView1.RowCount - 1;
DataGridViewRow row = dataGridView1.Rows[RowIndex];
row.Cells["Symbol"].Value = symr["Symbol"].ToString();
row.Cells["Symbol"].Style.BackColor = Color.LightYellow;
}
I wish to edit the data values based upon the row descriptor. What is the most efficient way to find the row index based upon the descriptor?
I could do this way:
int rowIndex = -1;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells[0].Value.ToString().Equals(symbol to be found))
{
rowIndex = row.Index;
break;
}
}
But is there a better(faster), more direct way to do it without using a foreach loop?
Also, is the DataGridView the best control to use to display fast changing dynamic data?
Many Thanks
modified on Tuesday, October 12, 2010 10:52 AM
|
|
|
|
|
a partial answer:
I tend to make sure I have a column with unique data, i.e. a primary key or something equivalent (the row number itself would be OK). It hasn't to be visible, as long as it is present, your code can use its content to easily identify rows, even when the rows in the grid have been reordered.
|
|
|
|
|
Luc:
Each row is in fact unique (there are now duplicate symbols). What would you say is the best way to quickly get the row index associated with a given symbol. Please post a code statement
Thanks
|
|
|
|
|
you won't get code. I barely understand half of your message. What is "symbol", what is "row descriptor"?
If you click in a row, you get the RowIndex in DataGridViewCellEventArgs.
If you need to search for some text, and you didn't databind the DGV to a searchable source, you have to create your own searching loop.
|
|
|
|
|
Luc
I've updated my original question, Hopefully the question I'm asking is now clear. Regarding "symbol" these are the values put into column[0] of the DGV. I'm trying to get the row index based upon the symbol values originally written into the DGV. Datatables have a Select feature, I was wondering wether there is something similar for a DVG.
|
|
|
|
|
You could keep a dictionary translating your "symbol" into either a row index or, better IMO, a row reference.
AFAIK a DGV has no "find" functionality. This[^] seems to confirm that.
|
|
|
|
|
For anybody else with this question, I settled on this approach:
int rowIndex = -1;
try
{
DataGridViewRow row = dataGridView1.Rows
.Cast<DataGridViewRow>()
.Where(r => r.Cells[0].Value.ToString().Equals(symbol to be found))
.First();
rowIndex = row.Index;
}
catch
{
}
Perhaps somebody with more knowledge could say which of the two approaches (the other given in my original post) is the most efficient.
|
|
|
|
|
I want to create a DataSet that has two tables which are connected by a LEFT JOIN. All MSDN examples tell that if two tables are connected by a parent-child relation, I can add the two tables to DataSet object, create a DataRelation object by passing (parent, child) as parameters, and then add the DataRelation to the DataSet.
But no example tells how to relate the tables if they are connected by a JOIN. I don't think we can create DataRelation for JOINs. If we can, how? And how to differentiate between JOIN, LEFT JOIN, FULL JOIN etc. while creating DataRelation?
Any help is appreciated.
It's better to know some of the questions than all of the answers.
Pravin.
|
|
|
|
|
Try the Database forum?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I thought about that before posting, but this one is more of an ADO.NET question than a database question, so thought I'll be in good company here.
The DB forum doesn't have many 'programming' questions, but if I don't get any answer here, probably I'll try my luck there as well.
It's better to know some of the questions than all of the answers.
Pravin.
|
|
|
|