|
Hi all,
i am having a data grid view control in my windows form, now i would like to add all rows of data that in dtSearchDetails that i got from here: dtSearchDetails = taSearchDetails.GetDeliveryDetails(id); into my data grid view
here is my code:
DeliveryDetails.tblSearchDeliveryDataTable dtSearchDetails = new DeliveryDetails.tblSearchDeliveryDataTable();using (DeliveryDetailsTableAdapters.tblDeliveryIdByDateTableAdapter taGetId = new DeliveryDetailsTableAdapters.tblDeliveryIdByDateTableAdapter())
{
int id = 0;
dtDetailsByDate = taGetId.GetIdByDate(dtpSearchByDate.Text);
using (DeliveryDetailsTableAdapters.tblSearchDeliveryTableAdapter taSearchDetails = new DeliveryDetailsTableAdapters.tblSearchDeliveryTableAdapter())
{
int n = dgvDeliveryDetails.Rows.Add();
for (int i = 0; i < dtDetailsByDate.Rows.Count; i++) //assume that dtDetailsByDate.Rows.Count = 3
{
id = Convert.ToInt32(dtDetailsByDate.Rows[i][dtDetailsByDate.IDColumn].ToString());
dtSearchDetails = taSearchDetails.GetDeliveryDetails(id);
foreach (DeliveryDetails.tblSearchDeliveryRow dr in dtSearchDetails)
{
dgvDeliveryDetails.Rows[n].Cells[0].Value = dtSearchDetails.Rows[i][dtSearchDetails.ClientCompanyColumn].ToString();
dgvDeliveryDetails.Rows[n].Cells[1].Value = dtSearchDetails.Rows[i][dtSearchDetails.DeliverDateColumn].ToString();
}
however, these codes are not working, the compiler says: there is no row at position 1, and it points to this statement: "dgvDeliveryDetails.Rows[n].Cells[0].Value = dtSearchDetails.Rows[i][dtSearchDetails.ClientCompanyColumn].ToString();"
Thanks heapls
Andie
|
|
|
|
|
Hi Andie,
you are iterating through the row count of dtDetailsByDate, but using the index i with the rows in dtSearchDetails. Are you sure that both tables have the same row count?
Regards
Sebastian
P.S.: If you post your code between <code></code> it is better to read.
|
|
|
|
|
no, they dont have the same row count, that's the problem i discovered, but dont konow how to fix it
|
|
|
|
|
Okay, so you could check if a row at index i exists before you try to access it. But I think there is a underlying problem. What should your code do exactly?
|
|
|
|
|
Hello,
i am developing a ASP.NET C# 'BACKUP' application. so here i have to display file and folders of computer in tree view, so that user can selected which they want to create a back up. but i am begineer to this platform. also i have searched many code for this but i am not getting it.
can any one provide me the code for this.
please it is very help full to me.
|
|
|
|
|
kavitaBC wrote: so here i have to display file and folders of computer in tree view
Files and folders of server or the client machine? If it is server, use Directory class and work with the methods provided. If it is client machine, ASP.NET can't do that.
BTW, this is C# forum, not ASP.NET.
|
|
|
|
|
You have to code a function that recursively scan a folder for files/folders and add it to the treeview.
You can start with
//this code shows a dialog to choose a folder
FolderBrowserDialog FBD = new FolderBrowserDialog();
FBD.ShowDialog();
string path = FBD.SelectedPath;
//with this you get files in the folder
DirectoryInfo dirInfo = new DirectoryInfo(path);
FileInfo[] filInfo;
filInfo = dirInfo.GetFiles("*.*");
DirectoryInfo subDir = dirInfo.GetDirectory();
Or Something like this. Hope it helps.
|
|
|
|
|
Hi guys,
I'm trying to make the listview to look exactly like the one in Windows Explorer on Vista.
I used the SetWindowTheme function from uxtheme to theme it, but I cant get rid of the focused border. I noticed that when the form that contains the listview lose focus there's no ugly dotted border. So is there any way to take away the focus from a single item in the listview?
Thanks in advance
Matteo
|
|
|
|
|
Hello,
i want to change a Property from a class to a specified Value. How can i do this over a function/method like
ChangeValue("MyProperty","Value");
i cannot change them over myClass.myProperty = Value, because everytimes the Property changes.
Many Thanks
|
|
|
|
|
This can be done using reflection:
Type myType = myObject.GetType();
System.Reflection.PropertyInfo myProperty = myType.GetProperty("MyProperty");
myProperty.SetValue(myObject, "Value", null);
For reference: MSDN[^]
|
|
|
|
|
hi,
many thanks, but i got one problem, if i want to change a location, or a color-value or something else like (myObj.Location.x) i get a NullReference-Exception.
So i tried it with
Point myPoint = myObj.Location;
....
System.Reflection.PropertyInfo myProperty = myType.GetProperty("X");
myProperty.SetValue(myObject,20,null);
but of course, the button doesn't change.
How can i solve this Problem?
|
|
|
|
|
From your code is not clear what is causing the error.
Do the following checks:
- what type represents myType (to work correctly it must be of type Point)?
- the myProperty variable returned by GetProperty has value or is null (if myProperty is null it means that the property "X" does not exist in myType)?
- myObject has value or is null?
|
|
|
|
|
Ok, just easy
I want to change the Location of a Button. Or maybe the backColor of a Panel, but i can't access this Properties.
If i try it with a code something like this:
Point r = Button1.Location;
// Change the Property "X" of "r"
but then the button doesn't change the location, of course, because i change the value of "r".
|
|
|
|
|
True, point is a value type
You can always do this:
Type locationType = Button1.Location.GetType();
PropertyInfo xProperty = locationType.GetProperty("X");
xProperty.SetValue(Button1.Location, 10, null);
|
|
|
|
|
No, it doesn't nothing... =( Exactly copied and pasted...
|
|
|
|
|
I tried it: actually, the not-reflection property assignment (button1.Location.X = 10; ) gives a compiler error "Cannot modify the return value of 'System.Windows.Forms.Control.Location' because it is not a variable".
As always, MSDN[^] has the answer: Because the Point class is a value type (Structure in Visual Basic, struct in Visual C#), it is returned by value, meaning accessing the property returns a copy of the upper-left point of the control. So, adjusting the X or Y properties of the Point returned from this property will not affect the Left, Right, Top, or Bottom property values of the control. To adjust these properties set each property value individually, or set the Location property with a new Point.
Sure you choose a tricky case to practice Reflection
|
|
|
|
|
hello
anyone from financial industry? seen one of those trading/risk application with price updates flickering on screen? well i have seen a number of such apps and I suspect most come with architecture of a frontend gui subscribing for updates from some sort of Price and Position Server/Service. Communication for most part been done in form of sockets with custom implementation or some sort of massaging middleware.
Just a thought, has anyone come across one application where communication is done via remoting or even Web Services? [This is a performance tuning question]
thanks
dev
|
|
|
|
|
Hi all,
We are just starting out with C# programming. In the past we used Delphi. The first thing we noticed is that there are much less components available. Can anyone advise us where to get/purchase a good package with components? We need at least some way to use USB.
Thanks in advance!
Greetings,
Dreeke
|
|
|
|
|
hello
post this question in VIsualStudio forum
|
|
|
|
|
Hi Dreeke,
what kind of components do you need? UI Components (e.g. Infragistics) or more sublevel components like Microsoft Enterprise Library.
For USB you could start with this article: http://www.codeproject.com/KB/cs/USB_HID.aspx[^]
Regards
Sebastian
P.S.: I wouldn't say that .NET has missing components, it is just that you have to go on your own and search for them... for example by using google etc.
|
|
|
|
|
Hi Sebastian,
I have found the USB_HID article just before I read your answer but thanks anyhow. Besides USB we don't miss any components at the moment but we were wondering why there are only a few components available compaired to Delphi. We just want to be one step ahead of the Direction's needs...
I just can't find some list of components. It is hard to search if you don't know how things are named.
Greetings,
Dreeke
|
|
|
|
|
Here is a component for working with USB: LibUsbDotNet[^]
For UI components I suggest developer express or Telerik.
|
|
|
|
|
Hello Giorgi,
That are nice tips! We will investigate them at once. Thanks!
Greetings,
Dreeke
|
|
|
|
|
There are alot of components out there.
Here is a small list:
Devexpress
Infragistics
Telerik
Component Ace
Syncfusion
Component Factory
There are alot more but this should get you started I think.
On a personal note, I use the devexpress controls and so far no complaints and there support is the best I'v seen.
|
|
|
|
|
Thanks Tom, this gives me a lot of openings!
Greetings,
Dreeke
|
|
|
|