|
I have been wracking my brain for hours on this problem.
I have a DataGridView object that has a DataGridViewComboBoxColumn inside of it. The combo box displays fine and is populated from an Access database. The column has the Primary key mapped to the ValueMember variable and the column 'Type' is mapped to DisplayMember.
What I need is for each of these combo boxes to have their selected index (I think it is the Value property under DataGridViewComboBoxCell, but I'm pulling at straws at this point) be populated from another table. This took me about 6 seconds in Access. My problem is I cannot even find a way to access the Value/SelectedIndex of the Combobox once I place it in the DataGridView.
If anyone could help me out I'd greatly appreciate it.
Here is the code:
OleDbConnection dbCon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"" + "NGDemoSetup.mdb" + "\"");
DataSet ds = new DataSet();
DataSet cboDs = new DataSet();
DataGridViewComboBoxColumn cboCol = new DataGridViewComboBoxColumn();
dbCon.Open();
OleDbDataAdapter da = new OleDbDataAdapter("SELECT AddrType,isRange,Value1,Value2 FROM LOCATIONINFO", dbCon);
OleDbDataAdapter cboDa = new OleDbDataAdapter("SELECT * FROM ADDRESSTYPES", dbCon);
da.Fill(ds, "LocationInfo");
cboDa.Fill(cboDs, "AddressTypes");
cboCol.Width = 100;
cboCol.DataSource = cboDs.Tables[0];
cboCol.ValueMember = "ID";
cboCol.DisplayMember = "Type";
DataTable dt = ds.Tables["LocationInfo"];
grdAddressInfo.DataSource = dt;
grdAddressInfo.Columns.Insert(0, cboCol);
grdAddressInfo.Columns[0].HeaderText = "Address Type";
grdAddressInfo.Columns[1].HeaderText = "Ranged Value";
grdAddressInfo.Columns[2].HeaderText = "From";
grdAddressInfo.Columns[3].HeaderText = "To";
dbCon.Close();
|
|
|
|
|
You can create objects of the items and then add the list of objects to the combo box.This way you can access the selected object from the datagridview cell.
|
|
|
|
|
pls help guys
im a intermediate level in c#....anyone guide me from begining to end to create a migration project in
"<big>text parsing or automatic segmentation of text</big>"
from c and c++ to c#...
i'll answer ur doubts regarding this...kindly help me.... its my college project..... time duration is 25 days<b></b>
|
|
|
|
|
|
Can you give us more detail on what you are looking at?
|
|
|
|
|
More details? He's looking for someone to do his homework.
only two letters away from being an asset
|
|
|
|
|
dear friend not like tat i just need ur help and support.. since it is my first project
|
|
|
|
|
actually set of adresses in any form will be given as input,
the program has to convert it into the standardise format.. and correct spelling mistakes and delete unnecessary spaces and hashes
then can u also tell me wat we should use instead of pointers in c#
|
|
|
|
|
lawrenceinba wrote: then can u also tell me wat we should use instead of pointers in c#
C# uses references. An instance of a class is passed as a refernce, an instance of a struct is passed by value. It is handled implicitly by the run time, you don't have to explicitly use them like you do in C++.
lawrenceinba wrote: the program has to convert it into the standardise format
Step 1 is to define what you mean by "the standardised format"
|
|
|
|
|
standard format like this
1.house no
2. streeet name
3.city
4 district
5. country
and so on
also it should remove spelling mistakes.....
n number of address will be passed and using hmm training we should train and make the output efficient
|
|
|
|
|
lawrenceinba wrote: standard format like this
1.house no
2. streeet name
3.city
4 district
5. country
That doesn't tell anyone enough. How are the parts of the address separated from one another? Is it in XML, field length delimited, comma separated, etc.
lawrenceinba wrote: it should remove spelling mistakes.....
From an address? How is it going to know that? Do you have a dictionary of approved spellings?
lawrenceinba wrote: using hmm training we should train and make the output efficient
What is "hmm training"? Is that some sort of generic algorithm?
Define what you mean by "efficient" output.
|
|
|
|
|
Do your own homework.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
lawrenceinba wrote: guide me from begining to end
It is your homework - How about you trying to do it then if you get stuck come back and ask for specific help.
lawrenceinba wrote: a migration project in
"text parsing or automatic segmentation of text"
That is a bit on the vague side. A project title tells people very little about what it actually needs to accomplish. How about if I tell you the project title of what I'll be doing in January: "Opera Integration upgrade to version 5" - Now, what does that actually tell you?
|
|
|
|
|
Colin Angus Mackay wrote: How about if I tell you the project title of what I'll be doing in January: "Opera Integration upgrade to version 5" - Now, what does that actually tell you?
It tells me that you're working on a sideline project providing scaffolding for the dresses of the "waif-like" opera singers.
|
|
|
|
|
Pete O'Hanlon wrote: It tells me that you're working on a sideline project providing scaffolding for the dresses of the "waif-like" opera singers.
Nice try! But, ultimately, incorrect.
|
|
|
|
|
ya i'll be doing i just need help from u guys
|
|
|
|
|
Well, when you have something specific that we can help with then please let us know.
|
|
|
|
|
Hey,
I have a List of Points that makes up a line getting from users input. What I would like to do is take the list and create a new list of points where all the points are evenly spaced with an equal, or set distance apart. Does anyone know of the best way to do this, or any good resources to look at. I've searched around but not been able to find what i'm looking for.
Thanks
--
John
http://blog.yeticode.co.uk
|
|
|
|
|
How about this.
void AddMidpoints(List<Point> points) {
for (int i = points.Count - 1; i >= 1; i -= 1) {
points.Insert(i, midpoint(points[i], points[i - 1]));
}
}
Point midpoint(Point p1, Point p2) {
return new Point(((p1.X + p2.X) / 2), ((p1.Y + p2.Y) / 2));
}
|
|
|
|
|
I understood the question as taking a line created by a number of points and creating a new set of points that construct the same line, but with the same number of points evenly distributed across the line. If that is the case, here is a solution. Theoretically, all you need to do is calculate the length of the line and divide it into even segments according to the number of points provided by the user. Where P1 and P2 are the end points of the line, and n is the number of points provided by the user; you can calculate an x offset as (| P1.X - P2.X |) / n and a y offset as (| P1.Y - P2.Y |) / n . You can then construct a collection of points containing the first and last point provided by the user along with an additional n - 2 points (indices 1...n-1) where the X coordinate = P1.X + (index * x offset) and the Y coordinate = P1.Y + (index * y offset) .
Pseudocode:
N = userPoints.Count
P1 = userPoints[0]
P2 = userPoints[N - 1]
xOffset = Abs(P1.X - P2.X) / N
yOffset = Abs(P1.Y - P2.Y) / N
List newPoints = new List(N)
newPoints.Add(P1)
For I = 1; I < N - 1; I++
newPoints.Add(new Point(P1.X + I * xOffset, P1.Y + I * yOffset))
newPoints.Add(P2)
Keep It Simple Stupid! (KISS)
|
|
|
|
|
Hi,
I admit your approach is very KISS, however I doubt this is the right answer. You are assuming it is a straight line, but then why would the OP start of with a collection of points to define the line? It looks more like: here is a number of points, imagine a fluent line that goes through all of them and come up with new point that lie on that fluent line but now are equally spaced. So you might try some Bezier curves and calculate lengths on those (something I haven't encountered before).
|
|
|
|
|
Hello all and Happy new Year
I have a UserControl which contains a Label and a TextBox and I want to set the Label's Text in my main form. I know I can get a string as parameter in UC's constructor or define the Label, publicly. But I wonder if I can set the Text in Design mode. I mean is there any way to add a property for my UC so when I open Properties tab I can see that and change its value?
I hope I could explain well.
Thanks a lot
I died as a mineral and became a plant,
I died as plant and rose to animal,
I died as animal and I was Man.
Why should I fear? When was I less by dying?
-- Rumi[^]
My blog
|
|
|
|
|
|
Actually I didn't know from where I should start. I tried constructor but I have error adding UC in my windows form. I defined the Label publicly but I could only access the Label this way: UserControl.Label . I searched MSDN for Property and Attribute but I couldn't find anything yet.
Thanks for reply
I died as a mineral and became a plant,
I died as plant and rose to animal,
I died as animal and I was Man.
Why should I fear? When was I less by dying?
-- Rumi[^]
My blog
|
|
|
|
|
You can override the Text property of the usercontrol so as to set the entered text into the label.
Something like what is given below.
[Browsable(true)]
public override string Text
{
set
{
label1.Text = value;
}
}
This will let you set the text in design time.
|
|
|
|