|
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.
|
|
|
|
|
DataSet ds = new DataSet();
DataTable dt1 = new DataTable();
dt1.Columns.Add("PK", typeof(int));
DataTable dt2 = new DataTable();
dt2.Columns.Add("FK", typeof(int));
DataRelation Join = new DataRelation("Join", dt1.Columns[0], dt2.Columns[0]);
ds.Relations.Add(Join);
|
|
|
|
|
Shouldn't you have replied against the OP rather than somebody questioning where the post should go?
|
|
|
|
|
This is exactly what all the MSDN examples show. My questions are:
1. This code is for the case where we have a query like "SELECT something FROM dt1, dt2 WHERE dt1.PK=dt2.FK". Will this also hold good for a query like "SELECT something FROM dt1 JOIN dt2 on (dt1.PK=dt2.FK)"?
2. How does the statement
DataRelation Join = new DataRelation("Join", dt1.Columns[0], dt2.Columns[0]);
change if in case of a JOIN, I have a FULL JOIN, or a LEFT JOIN, or an OUTER JOIN etc.?
It's better to know some of the questions than all of the answers.
Pravin.
|
|
|
|
|
I agree this is more of a db question, but you're answer may not lie in thinking of the dataset as two tables. The underlying query will contain a join, but the dataset will still only contain a single result set table.
|
|
|
|
|
A JOIN produces one table, not two.
|
|
|
|
|
Ignore the people who say this is a database question. They probably have never worked with a DataRelation object and don't realize that ADO.Net allows you to essentially create an entire relational database in a DataSet.
The parent child relationships are determined by the cardinality of the two tables. If for every record in table A there can be many records in table B, then A is the parent and B is the child and vise versa. In the case of a left join, the table that may have nulls is always the child. In the case of a many-to-many relationship you should create two DataRelations, one in each direction.
|
|
|
|
|
And how does that answer the question?
|
|
|
|
|
Is there any function to return the kind of drive?
|
|
|
|
|
Hi,
I know three ways to get some information on physical devices:
1.
using the DriveInfo class
2.
using WMI, have a look at the WMI classes Win32_DiskDrive, Win32_LogicalDiskToPartition, Win32_PhysicalMedia, Win32_CDROMDrive; which ones you want depends on the information you need.
warning: not everything may be available to regular users under Vista/Win7 without going trough the UAC dialog.
3.
using Win32 functions (from kernel32.dll), which requires P/Invoke. Here is an example prototype:
[DllImport("kernel32.dll")]
public static extern int GetDriveType(string rootPathName);
For each of these, I refer to the MSDN documentation, Google, and some experimentation.
|
|
|
|
|
Hi, I have a server/client application. I want to block the clients' desktops to prevent pc usage. I also want to show a picture on the screen. Currently, I show a form covering the whole screen with topmost property set to true but it doesn't help much. Is there a better way to achieve that? Thanks!
|
|
|
|
|
Are you familiar with "kiosk mode"? if not, ask Google.
|
|
|
|
|
Hi Luc, Regarding to google results, some uses shell and some use win forms just like I do to implement kiosk. Is this what you mean or there is a speacial implementation for kiosk mode. Sorry to bother you
|
|
|
|
|
all I know is it is called kiosk mode, there are some CP articles on it, and Google knows everything.
|
|
|
|
|
|
Thanks, the reference helped a lot
|
|
|
|
|
So the DataBindingComplete event tells me when the data binding for a control is finished but is there a way to check at any point whether or not the data binding for a control is finished? (ie not event driven)
What I'm trying to achieve is this:
I have two DataGridView controls on a form bound to different data sources and I have some code that I'd like to execute when either of their data binding operations are finished. So far so good, I write an event handler which consumes both of their DataBindingComplete events.
The problem is I also have some code which I want executed only once both of the controls are done with their data binding. I don't know for which control the event handler will fire first so it would have been convenient if I could do something like:
if (dataGridView1.isDataBindingComplete && dataGridView2.isDataBindingComplete)
{
}
I suppose I could maintain a global boolean or something but I'm sure there must be a more elegant way. Any ideas?
|
|
|
|
|
Since the DataBindingComplete event hands you the sender parameter containing the DataGridView which has completed binding, and the EventArgs which tells you the reason, why not just use the Tag property?
Set it to true when it binds and check if both tags are true at the end of the event handler.
Simple, and elegant.
[edit]I can't spell for toffee this morning![/edit]
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|