|
ArrayList names = new ArrayList();
foreach(Control ctrl in myPanel.Controls)
{
if(ctrl is Textbox)
{
names.Add(ctrl.Name);
}
}
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
thanks for your reply
i think i need to know a lot about u
my approach was about 4 lines of code
but your reply has help me understand.
i'm from ghana and working as a programmer
with the softtribe
|
|
|
|
|
hi
im new to c# and this is my first attempt to create a database.. right now i only have a concept, i donno how to get started or what i need to do exactly to carry out my plan..
i've separated my groups of data in tab pages.. so now, each tab page consist of a different type of data..
1) when the user saves the tab page of data, i want the data to go into the database.. but how do i "throw" the data into my database?
2) i need to create a few sets/types of sample data eg. types of food taken and personal particulars.. where do i go to to create my sample data n how do i store these sample data in my database?
3) more importantly, im not even sure what database to create.. microsoft access or microsoft sql server or others.. which database is the best/easiest to use for my app?
4) my app is something like this >>
let's say i've these buttons : updateBtn1, viewBtn1, updateBtn2 n viewBtn2.. the user chooses what he wants to click and the page will be displayed.. if this button is to view only and it is to open a tab page about types of food taken, im supposed to retrieved only types of food taken from database and display in the tab page.. i need it to sort and only retrieve food taken and leave out personal particulars which is also kept in the same database..
if the button clicked is to open tab page to update food taken, i need to get the relevant data frm database and let user edit those data before he saves them again to database..
so my question is how do i open/display/retrieve only the relevant data for THAT tab page AND how do i save it back to database? note: the same data shd NOT be written again to database, only add NEW data in to database.. how to do this? when the user loads (whether to view or update) tab page by clicking the button, i want the page to display both old data + new data in a datagrid for example (old data means data that's already in database that is my sample data & new data means the data that was updated/added in to database..
i really appreciate it if u cld provide me with some examples of codes and how they work or some help articles or anything that u think will help..
thank you so much for trying to help! =)
|
|
|
|
|
hi i think u should read more about the database connection
and about dataset
with this you will have more idears about .net database
|
|
|
|
|
|
Iam searching for a way to display incoming strings(over the network) and the resulting outgoing string, in an automatically scrolling window,
at the moment i use two textfields but they always run full.
windows should look like this:
______________________
| | |
| | |
-----------------------
in the middle there should be a scrollbar or therelike to scroll to the previous strings.
in the left field the incoming string is printed, and in the right field the response string.
the both strings shall be in the same line always too, so one can see what incoming string belongs to wich outgoing string.
so any ideas on what to use for that in a windows form in visual c#?
thnx in advance, mike
|
|
|
|
|
Hi!
I can't seem to make it work. I select a row in a datagrid and press a delete button. That row is then deleted. But if i add/delete many rows, then close and reopen my dialog and try to delete a row again, the row with index 0 is deleted instead of the one i have selected. I have tried to use currency manager to delete and everything, but I can't make it work properly.
This is how I delete a row:
<br />
if(_currencyManager.Current.GetType() != typeof(DataRowView)) return;<br />
<br />
DataRowView dr = (DataRowView)_currencyManager.Current; <br />
dr.Delete(); <br />
_currencyManager.EndCurrentEdit();<br />
_currencyManager.Refresh(); <br />
_dtPplan.AcceptChanges();<br />
I set the currency manager like this:
<br />
_currencyManager = (CurrencyManager)this.BindingContext[dgPplan.DataSource, dgPplan.DataMember];
And fill the table with data like this each time i open the dialog. Just so i'm sure it got the latest data:
<br />
_dtPplan.Rows.Clear();<br />
foreach(PPlan pPlan in valueObject.PPlan) <br />
{ <br />
DataRow dr = _dtPplan.NewRow();<br />
dr[NetworkKeywords._cCriteria] = pPlan.Criteria;<br />
dr[NetworkKeywords._cParameter] = pPlan.Parameter;<br />
dr[NetworkKeywords._cValue] = pPlan.Value;<br />
dr[NetworkKeywords._cUnit] = pPlan.Unit;<br />
_dtPplan.Rows.Add(dr);<br />
}<br />
_dtPplan.AcceptChanges();<br />
<br />
_currencyManager = (CurrencyManager)this.BindingContext[dgPplan.DataSource, dgPplan.DataMember]; <br />
I really need help on this. This datagrid/datatable is driving me crazy.
Thanks in andvance
Atle
|
|
|
|
|
I would suggest you that,instead of having a delete button, u keep a contextmenu for the datagrid, and in the delete menu click event,u delete the selected row..sumthin like this..
int rowIndex = dataGrid1.CurrentRowIndex;
dataTable.Rows[dataGrid1.CurrentRowIndex ].Delete();
//then call the function to delete the row
and u retrieve the data correctly
try it..datagrids n datatables ain't so bad
|
|
|
|
|
I also have an "Add" and "Delete All" button that I need. The way you are mentioning her will work with a button too won't it? Just use your code inside the buttons aciton?
What happens when I sort the datagrid? Then the row indexes in the datagrid won't correspond to the row indexes in the datatable will they? Only the datagrid's rows are sorted, or? Then I will need the currency manager to keep track of that?
- Atle
|
|
|
|
|
I agree with deep7.
You can have a context menu with the following items
Delete,
Delete All
You can add a new row on mouse click on the white region.
private void OnGridMouseUp(object sender, MouseEventArgs e)
{
//Get Current Point
this.hitTestGridInfo = this.dataGridAllocation.HitTest(new Point(e.X, e.Y));
//Capture Grid Body Event
if (this.hitTestGridInfo.Type == DataGridEx.HitTestType.None &&
e.Button == MouseButtons.Left )
{
newDataRow = this.dataTable.NewRow();
this.dataTable.Rows.Add(newDataRow);
}
}
As far as sort order is concerned, you can use,
private DataRow GetDataRowAt(int index)
{
DataRow dataRow = null;
CurrencyManager currencyManager = null;
currencyManager = (CurrencyManager)this.BindingContext[this.dataTable];
if ( currencyManager != null )
{
dataRow = ((DataRowView)currencyManager.List[index]).Row;
}
return dataRow;
}
Live Life King Size
Alomgir Miah
|
|
|
|
|
Looks like the datagrid is messed up after refilling the datatable or something. You see how i fill it with data in my first post. Is there another way to do it? I need to fill in some data from an arraylist. I refill the datagrid according to what I select in a combobox.
It seems my problem is that after clearing and refilling the datatable with data a couple of times (selecting differend things in the combobox), the datagrid returns selected row index = 0 for each and every row i press. Then suddenly it can return index out of bounds exception when I press a row??
- Atle
|
|
|
|
|
Hmm....seems like it likes
<br />
foreach(DataRow row in _dtPplan.Rows) <br />
{<br />
row.Delete();<br />
}<br />
_dtPplan.AcceptChanges();<br />
for deleting all rows than
<br />
_dtPplan.Rows.Clear()<br />
I have to test it a little more, but it seems like the index problem is gone now. It works with the add and delete buttons in the form by the way. Thanks for your help.
- Atle
|
|
|
|
|
hi all,
I need to shedule a Task in windows 2000.I can easily do it using Control Panel--->Sheduled Task ..
But How am I shedule a task using a C# Application..?
Can any one please help me.?
thanks in advance..
|
|
|
|
|
|
I'm using
System.IO.Directory.GetCreationTime(folderName)
to get the creation date of a folder, but it throws an ArgumentOutOfRangeException with the message
"Specified argument was out of the range of valid values.
Parameter name: Not a valid Win32 FileTime."
The folder in question is on a CDR that was burnt on a PC with a different datetime locale. Why is it that Windows Explorer can display the datetime of the folder without any problems, but the .net framework chokes on it? Does System.IO.Directory require some sort of CultureInfo to parse dates? If so, where do I specify this?
Thanks in advance
|
|
|
|
|
I am trying to limit the amount of time an ASP.NET Web Service can spend processing a client’s request.
Currently if the client sets it’s timeout to Infinite the server will allow the request to complete; however I want to stop the request and send a custom response back to the client after a specified time limit.
What is the best way of achieving this?
|
|
|
|
|
How can i get the hard disk Id or the motherboard ID programatically?
hosny
|
|
|
|
|
|
hi all,
in my code i'm populating a combobox which is one of the columns in th datagrid.
i want the combobox to be populated with data from two tables from the database.
like for example the 'name' and the 'Description'.
At present i'm getting only the 'name in the combobox.
how to get its description also ??
|
|
|
|
|
did you mean by using data binding or by the code
if you mean data binding i think you can not
bind combo box to two fields
in the code get the data and loop for each recored add the two fields value
|
|
|
|
|
i'm getting only the names in the combobox, but i also want the description to be next to the name separated by space.
m doing it as below...
newColumnStyle.MappingName = "New";
newColumnStyle.HeaderText= "New";
newColumnStyle.Width = 101;
newColumnStyle.MyComboBox.Items.Clear();
for(int i = 0; i < getData.Length; i++)
newColumnStyle.MyComboBox.Items.Add(getData[i].name );//here how to add in the combobox the 'getData[i].description'
tableStyle.GridColumnStyles.Add(newColumnStyle);
any help appreciated
|
|
|
|
|
try somthing like this
newColumnStyle.MyComboBox.Items.Add(getData[i].name + " " + getData[i].description)
|
|
|
|
|
thanx...silly me dinn think of concating...
but my problem ain't solved yet.
when i select one of the names, and then i fill in other columns other details, and click on 'save' button, only the name should be saved and not the description...
in save button click,
for each row,
for (int i = 0; i < dataTable.Rows.Count ;i++)
{
testData.name = Convert.ToString(dataGrid1[i ,2]).Trim();
//other details from the datagrid
//then i call a function to add the details from the datagrid in the database
addDetails(testData);
}
thanx for helping
|
|
|
|
|
you need to extract name only
some thing like the following will extract it
//text that contain both name and description
//" " the sperator replace it with your own
<br />
string name=text.Substring(1,text.IndexOf(" ")+1);
then testData.name=name
|
|
|
|
|
thank u
|
|
|
|