|
You can use controls in a loop using FindControl(string name) (self made method).
However i would like do a loop with objects like:
string str1 = "test"
string str2 = "test"
string str3 = "test"
for (int i = 0; i < 5; i++)
{
str[i].Text = "test2";
}
Also tryed:
string new = (string)str[i];
Also didn't work.
Any idea/methods for doing something like this?
Thanks
|
|
|
|
|
No, you can't create a few objects named like this and then try and iterate through them like they are in an array.
Either add them to a collection, and iterate through that:
String str1 = "test";
String str2 = "test";
String str3 = "test";
List<string> strings1 = new List<string>();
strings1.Add(str1);
strings1.Add(str2);
strings1.Add(str3);
for (int i = 0; i < 3; i++)
{
strings1[i] = "test2";
}</string></string> Or create an array of them to begin with:
String[] strings2 = new String[3];
strings2[0] = "test";
strings2[1] = "test";
strings2[2] = "test";
for (int i = 0; i < 3; i++)
{
strings2[i] = "test2";
}
Simon
|
|
|
|
|
Aha yes i figured as much.
Thanks anyway.
|
|
|
|
|
Hi,
I have upload an image in to image column but i have no idea to get it from DB and displaying it in Image control or Bitmap.Is it possible to display?Then plz guide me...
|
|
|
|
|
|
Hi
Thanx for that link but it uses file to store and retrieve.Is it same for database retrieval.And also i want that image to display in some specific area of my page .
|
|
|
|
|
It stores data in database. In order to show it on form you can use Image.FromStream method to construct the image after you read data from database in stream.
|
|
|
|
|
K thanks i will check it out...
|
|
|
|
|
do you what to display images store in a database? search here in codeproject for samples. If you get stuck in debuging or for something else ask here, we help.
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Hi,
I want to write a some data, as well read it from USB port.
I am able to write the data, But unable to read it. Even the
SerialDataReceivedEventHandler is not firing an event.
I am getting TimeOut exception. Please help me to solve the problem.
Reagards
Shiva
|
|
|
|
|
I think you have to check what kind of a device it is,
HID devices uses in and out -put reports.
Not really an answer but i hope it helps you a little further.
|
|
|
|
|
hi,
how to add control like button from one Form to another Form at runtime?
i have tried this one :
Form2 objForm2 = new Form2();<br />
objForm2.Controls.Add(this.button3);
i think button3 add on Form2 with successfully but.......new added control "button3" not shown on Form2 why?
|
|
|
|
|
A GUI control can't appear on two forms at the same time.
Just like you can't have the same button appear twice on one form. A GUI control has only 1 visual representation at a time. If you want two buttons you need to create 2 buttons, not try and use the same button twice.
(You can create 2 buttons and attach them both to the same event handlers if you want them to call the same code)
Simon
|
|
|
|
|
i used following code:
frmTimetablePopup objfrmTimetablePopup = (frmTimetablePopup)Application.OpenForms["frmTimetablePopup"];<br />
DataGridView grd = new DataGridView();<br />
grd.Name = "grd";<br />
grd.Location = new Point(310, 300);<br />
grd.Size = new System.Drawing.Size(600, 600);<br />
DataGridViewTextBoxColumn grdCol = new DataGridViewTextBoxColumn();<br />
grdCol.HeaderText = "Days";<br />
grdCol.Name = "Col1";<br />
grdCol.Width = 50;<br />
grdCol.DefaultCellStyle.BackColor = Color.CornflowerBlue;<br />
grd.Columns.Add(grdCol);<br />
objfrmTimetablePopup.Controls.Add(grd);
but fail ........
|
|
|
|
|
You're code works fine for me. You're setting the location to 310,300. Is this off the edge of your form.
grd.Location = new Point(310, 300); Try setting it to 0,0 instead.
Simon
|
|
|
|
|
believe me it's does not work.......
objfrmTimetablePopup.Controls.Add(grd);
after run the above coding.......objfrmTimetablePopup contains the "grd" but where ? i don't know![Confused | :confused:](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_confused.gif)
|
|
|
|
|
zeeShan anSari wrote: believe me it's does not work.......
Well the code is fine and it works fine for me, so it is something you are doing wrong somewhere else.
zeeShan anSari wrote: objfrmTimetablePopup contains the "grd" but where ? i don't know
I just gave you a suggestion:
I wrote:
You're setting the location to 310,300. Is this off the edge of your form. Try setting it to 0,0 instead.
Have you tried that?
Did it work?
What happened?
Simon
|
|
|
|
|
i obey your order as
grd.Size = new System.Drawing.Size(0,0);
and i also check foreach (Control ctr in objfrmTimetablePopup.Controls)
{
MessageBox.Show(ctr.Name);
}
than messagebox show "grd" name also...........but grd not shown
|
|
|
|
|
i found problem is here
private void btnRoomT_Click(object sender, EventArgs e)<br />
{<br />
<br />
frmTimetablePopup objfrmTimetablePopup = new frmTimetablePopup();<br />
GUIUtility.CompileRooms();<br />
objfrmTimetablePopup.ShowDialog();<br />
<br />
}
if i put this code objfrmTimetablePopup.ShowDialog(); on
GUIUtility.CompileRooms();<br />
method than objfrmTimetablePopup show grid .........
|
|
|
|
|
Hi,
here is my code
protected void btn_Click(object sender, EventArgs e)
{
con = new SqlConnection("user id=mak;pwd=mak;initial catalog=Smskwik;data source=AMEDALA");
da= new SqlDataAdapter("select * from Tbl_Country where Country_Id="+txt_id.Text+"",con);
ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
here am displaying result in gridview but i want to display this output in word document in a table formatl.
Please help me regarding this.
Thank you
|
|
|
|
|
|
Thank you for reply.
That is for window application.but i need for web application.Actually i dont have much idea about concept.
Please help me regarding this
Thank you.
|
|
|
|
|
Ok, what I assume you want to do then is create a word document dynamically and allow the user to download it. You will still probably need to use VSTO to create the word document. You will need to have word installed on the server (which by the way I don't think is supported by MS).
Why do you want to make it available as a word document? This ties your users to MS. What if one of your users doesn't have word? You would probably be better going for a more universal document format like PDF. There are plenty of commercial and free PDF libraries available for .net
You need to ask in the asp.net forum for how to go about doing making the created document available for download.
Simon
|
|
|
|
|
Sorry I know I am late to the thread, but I was just starting to look into document automation related topics on the server side and had some additions to make:
If we are talking about Word 2003 or 2007 documents and working with cached data (from a data source), the ServerDocument class is worth investigating (doesn't require Office on the server):
Accessing Data in Documents on the Server[^]. The how-tos and walkthroughs here all refer to workbooks but I think it applies to Word also.
If we are talking about Office 2007 (or later), then the Open XML format of documents comes into play. Check out the Open XML Format SDK 2.0[^] for more information. Here is an example of how to change the text in a table for a document: http://msdn.microsoft.com/en-us/library/cc850835(office.14).aspx[^].
|
|
|
|
|
Hi All,,
I want to get a Max value from a table and increment it by 1,, such as
if the max value is 1/50, It will be 2/50, but the problem how to get it from a db.
thanks all,,
|
|
|
|