|
farokhian wrote: How can i recognize each textboxes ;
Control have a Name property
farokhian wrote: ow can i move through these textboxes
Look at example at my other reply, you go through all Controls on form, not only TextBoxs
how can i access the cells of each datatable to set each textbox?
Depends. Are you using DataSet?
A Practical Guide to .NET DataTables, DataSets and DataGrids - Part 1[^]
That Article has 4 series. It shows how to do it programaticly
|
|
|
|
|
I create my database in sql server 2005 and connect to it in my project;
I execute each select command and put answers in datatable;
At first i want to say "thanks alot for your attention"
now i want to put each cells of datatable in textboxes.
Note:The result of each datatable is one row and total culumns of 7 datatable is 80;
I wanted to test your code but it doesn't work!
for example all the textboxes.text must have text "hellow" but in foreach loop it just check one of the controlls( it is a panel)and see that it is not textbox and then leave the loop!?
int nCount = 0;
foreach (Control ctr in this.Controls)
{
if (ctr is TextBox) // This is correct statement for checking if Object is specific type
{
TextBox tb = ctr as TextBox; // This line cast Object to TextBox
tb.Text = "hellow";
nCount++;
}
}
|
|
|
|
|
In that example it would go like this:
foreach(Control ctr in this.Controls)
{
if (ctr is Panel)
{
Panel p = ctr as Panel;
foreach(Control ctrP in p.Controls)
{
if (ctrP is TextBox)
{
TextBox tb = ctr as TextBox;
tb.Text = "hellow";
}
}
}
}
|
|
|
|
|
Excuse me sir;
Most of my textboxes in a usercontrol ;
How can i set the value of each these textboxes?
I mean that what should i put in foreach ? place:(Control ctr in ?.Controls)
i write my user control name but it doesn't work?
Note: i set the modifier of each textboxes "public"
and now i have access to the textboxes.text
can you tell me that what is the code of addressing to one cells of datatable?
|
|
|
|
|
If is impossible to loop all TextBoxes then refer one-by-one by writing 80 lines of code (with which I dont agree because if you try to implement Saksida Bojan's answer you can have proper solution)
farokhian wrote: addressing to one cells of datatable?
datatablename.Rows[0][0]
//Rows[0][0], first[0] means rows and second [0] means column
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
If you are using Controls, it doesn't matter if Controls are public, private or protected
http://i26.photobucket.com/albums/c104/bsaksida/Pic-1.png[^]
That is a link to a pic. That 3 textboxex at the button are in a custom control. I did not change anysthing at custom control expect added 3 text boxex
The code belov was inside OnLoad event
int nCountText = 0;
foreach (Control ctr in Controls)
{
if (ctr is GroupBox)
{
GroupBox gb = ctr as GroupBox;
foreach (Control ctrlGB in gb.Controls)
{
if (ctrlGB is TextBox)
{
TextBox tb = ctrlGB as TextBox;
nCountText++;
tb.Text = "This text box is within Group Box with a name: \"" + ctrlGB.Name + "\" and has Text: \"" + gb.Text + "\". Its Textbox number is: " + nCountText.ToString();
}
}
}
else if (ctr is TextBox)
{
TextBox tb = ctr as TextBox;
nCountText++;
tb.Text = "This TextBox is not Within Group box. Text Box name is: \"" + tb.Name + "\" And it is " + nCountText.ToString() + ". control found";
}
else if (ctr is UserControl1)
{
UserControl1 uc = ctr as UserControl1;
foreach (Control ctrUc in uc.Controls)
{
if (ctrUc is TextBox)
{
ctrUc.Text = "I Made it";
}
}
}
}
PS: If this is too hard, then i suggest go to regular 80 lines to change all TextBox text property
|
|
|
|
|
Are you using DataSet as container? Do you know how to extract data?
int nCount = 0;
foreach (Control ctr in this.Controls)
{
if (ctr is TextBox)
{
TextBox tb = ctr as TextBox;
tb.Text = dataSet1.DataTable1[nCount].Text1;
nCount++;
}
}
This is an example how to do it. Based on how you read your data, it may be a different than this example.
I Hope I put you in the Right direction.
|
|
|
|
|
I believe this is a better way of checking an object's type as there is only the one cast then just a null check...
foreach (Control control in Controls)
{
TextBox textBox = control as TextBox;
if(textbox != null)
{
}
)
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I have an XML Database that I am loading into a Dataset object in a C# 2008 Windows Forms project. I need to know how to access the individual fields and values. The actual database is not in my control, so I have to use it as given. And I need to be able to offer portions of the values for editing, while hiding others. So I need to how to access each individual field and value. Here is a very tiny mocked up version of the XML code:
<?xml version="1.0"?>
<database version="1.0">
<DatabaseItem name="FirstTable">
<DatabaseSubitem id="1">
<DatabaseField name="Id" value="1" />
<DatabaseField name="Freq" value="151955000" />
<DatabaseField name="Mode" value="Mode:Selective" />
</DatabaseSubitem>
<DatabaseSubitem id="2">
<DatabaseField name="Id" value="1" />
<DatabaseField name="Freq" value="151955000" />
<DatabaseField name="Mode" value="Mode:Selective" />
</DatabaseSubitem>
<DatabaseSubitem id="3">
<DatabaseField name="Id" value="65535" />
</DatabaseSubitem>
</DatabaseItem>
<DatabaseItem name="SecondTable">
<DatabaseSubitem id="0">
<DatabaseField name="access_p" value="500" />
</DatabaseSubitem>
</DatabaseItem>
<DatabaseItem name="ThirdTable">
<DatabaseSubitem id="0">
<DatabaseField name="access_Short" value="500" />
</DatabaseSubitem>
</DatabaseItem>
</database>
If there is an easier way than the Dataset object to process the database, please let me know.
Any help would be most appreciated.
Thanks,
Bruce
|
|
|
|
|
It will create table under dataset having three rows
(1) Id<br />
(2) Freq<br />
(3) Mode
You can access values easily by using
ds.Tables[0].Rows[0][0]
ds.Tables[0].Rows[0][1]
so on......
|
|
|
|
|
Is There any Other Way..!
System.Diagnostics.Process.Start(url + "?/" + txtFolderName.Text+"&UserName="+txtauthUserName .Text +"&Password="+txtAuthPassword .Text);
I also tried
System.Diagnostics.Process.Start(string,string,secure,string)
but not worked..!
Thanks..!
|
|
|
|
|
You are attempting to launch URL?
you need url to pass as Arguments not process name
System.Diagnostics.Process.Start("Chrome.exe", "http://www.google.com");
|
|
|
|
|
Saksida Bojan wrote: System.Diagnostics.Process.Start("Chrome.exe", "http://www.google.com");
I need pass username and password which is in windows authentication..!
like
System.Diagnostics.Process.Start("Chrome.exe", "http://www.google.com&username=xxx&password=XXX");
but in a secure way..!
|
|
|
|
|
So you wan't to pass username and password within URL
example:
http://userid:password@www.example.com
PS: I think I read somewhere, where IE8 disabled this kind of pass for security reasons. I can't confirm this statment
|
|
|
|
|
CoderOnline wrote: but in a secure way..!
That is not secured way. Only if site uses SSL. But it still won't prevent people to Hack using keyloggers and other tools. To be secured, Consumer need to make sure his/her computer software is up to date and using regular maintenance
|
|
|
|
|
Thanks For Your Info..!
I will Look into tht..!
|
|
|
|
|
hi
when i use this command for taking a picture :
wiaVideo[sendpic].TakePicture(out jpgFile);
the picture automatically save to this address:
C:\Documents and Settings\All Users.WINDOWS\Application Data\Microsoft\WIA
and after several use of program it gives this exeption:
system.outofmemoryexeption
how can i disable the picture automatically save in wia
thanks
|
|
|
|
|
hi all,
for compress the pdf file i use below code:
byte[] bufferWrite;
FileStream fsSource;
FileStream fsDest;
GZipStream gzCompressed;
fsSource = new FileStream(@"C:\Invoice.pdf", FileMode.Open, FileAccess.Read, FileShare.Read);
bufferWrite = new byte[fsSource.Length];
fsSource.Read(bufferWrite, 0, bufferWrite.Length);
fsDest = new FileStream(@"C:\Invoice.zip", FileMode.OpenOrCreate, FileAccess.Write);
gzCompressed = new GZipStream(fsDest, CompressionMode.Compress, true);
gzCompressed.Write(bufferWrite, 0, bufferWrite.Length);
fsSource.Close();
gzCompressed.Close();
fsDest.Close();
pdf file compress successfully but without extension(.pdf) .......where is problem?
|
|
|
|
|
zeeShan anSari wrote: pdf file compress successfully but without extension(.pdf) .......where is problem?
You named it .zip, just stop naming it .zip ?
On the other hand, renaming a gzip file to .pdf doesn't (to my knowledge) suddenly make it a pdf file, it just makes your computer think it is.
|
|
|
|
|
Thanks.........u r right
|
|
|
|
|
harold aptroot wrote: (to my knowledge)
Are you not sure about it ?
|
|
|
|
|
No, are you? Some PDF readers may (in theory at least) decide to detect it and decompress the file before loading
I wouldn't claim anything with full certainty without testing, and I'm not about to test every known PDF reader with gzipped pdf's
|
|
|
|
|
Today I have read CutePDF features, and it seems PDF supports commpresion. But it does not uses any zip, rar or any other container based compresion
|
|
|
|
|
I use the following code for a single file upload
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create("ftp://servername/filename.txt");
ftp.Credentials = new NetworkCredential("login", "password");
ftp.Method = WebRequestMethods.Ftp.UploadFile;
StreamWriter sw = new StreamWriter(ftp.GetRequestStream());
sw.Write(fileContent);
sw.Close();
Now - how do I upload multiple files in a single connection? Calling FtpWebRequset.Create with a different file name erases all the info about credentials, method etc. so I must set these again, which is annoying, but I suppose that the connection must be established again, which is not only annoying but also ineffective. Is there any better way?
|
|
|
|
|
I have a system where I need to compare files to see if they are the same. Is doing something like CRC the fastest/best way? I could do a byte by byte comparison but that seems like it would be slower.
I'm going to be keeping a list of files in a database so if I could come up with a number I generate just once, that would be great because I could store it in the database and then compare from then on (I'll be adding files to the list as time goes on so I need to compare them as it goes.)
I'm writing in C# v2.0 (although if I have to I might be able to go to 3.5).
Any thoughts would be appreciated.
TIA - Jeff.
|
|
|
|