|
No, there could be up to 30+ different doc types. I just used three for this example. Same goes for the other fields we need to map data for. Not all possible data is known until we receive the data and the same client doesn't always give us the same headings or file formats. nothing is considered finite between the data or the headers.
The reason for the multiple dgv's is to have a dgv per field where the data needs to be mapped. So, dgv1 is for Doc Types, dgv2 is for Purpose Types, dgv3 is for Occupancy Types and so on. So the second part of the third paragraph you wrote is correct "or to summarize (dgv1 = doctype, with a row for count of full doc, another for count of limited doc etc) with the other dgvs for the other field types". So the all the dgv's have three columns. The first will be the column that gets populated with the data from the file or the dgv on Form 1(example Full Documentation). The second column is a combo dropdown that contains the new code (F for Full Documentation). The third is a count of how many loans have Full Documentation. After all Doc Types have been recoded, then dgv on Form 1 needs to be updated. For example, Full Documentation is will be updated to F.
Once the dgv on Form 1 has been updated with the new codes from form 2, I will output it to excel for our SSIS (this is done and has been tested).
|
|
|
|
|
Hi there.
I have been thinking about this and have made a simple demo of something that I think might work. If you have the time would you give it a quick whirl to see if it might suit.
The demo consists of two forms each having a datagridview and a button, you will be able to work out the names of these controls from the code I will post. I will post the code for the two forms in separate posts, as it would otherwise be a very long post.
This is the test data I have used for the demo and if you could save it as TestData.csv in the directory with the executable for the demo, normally 'application-files-directory\bin\debug'
TestData.csv
Prop, Offer, Docs, Gtee, Figs
house, no, full, none, true
flat, true, part, complete, no
appt, no, no, yes, yes
bungalow, yes, full, no, no
mais, false, yes, no, comp
The code for the first form follows shortly.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Code for the first form.
public partial class ListEditorForm : Form
{
List<string> standardList = new List<string>();
Dictionary<string, string> headers = new Dictionary<string, string>();
DataSet headerDataSet = null;
DataTable headerTable = null;
MappingForm mappingForm = null;
readonly string dataFile = "TestData.csv";
FieldMappingDictionary docsDictionary = null;
public ListEditorForm()
{
InitializeComponent();
InitStandardList();
}
private void InitStandardList()
{
standardList.AddRange(new string[] { "Property", "Offer", "Documentation", "Figures", "Guarantee" });
}
private void ProcessMods()
{
StringBuilder selectBuilder = null;
foreach (string key in this.docsDictionary.Keys)
{
foreach (string val in this.docsDictionary[key])
{
selectBuilder = new StringBuilder();
selectBuilder.Append("UPDATE <yourtablenamehere**> SET Documentation = ");
selectBuilder.Append(key);
selectBuilder.Append(" WHERE Documentation = ");
selectBuilder.Append(val);
string updateQuery = selectBuilder.ToString();
}
}
}
private Dictionary<string, string> MakeHeaderDictionary()
{
Dictionary<string, string> result = new Dictionary<string, string>();
foreach (DataRow row in this.headerTable.Rows)
{
result.Add(row[1].ToString(), row[0].ToString());
}
return result;
}
#region ListEditorForm PROPERTIES ...............................
public Dictionary<string, string> Headers
{
get
{
return this.headers;
}
private set
{
this.headers = value;
}
}
private MappingForm MappingForm
{
get
{
if (this.mappingForm == null)
{
this.mappingForm = new MappingForm();
}
return this.mappingForm;
}
}
#endregion ListEditorForm PROPERTIES
private void ListEditorForm_Load(object sender, EventArgs e)
{
string headerLine;
using (StreamReader sr = new StreamReader(dataFile))
{
headerLine = sr.ReadLine();
}
headerDataSet = new DataSet("HeaderDataSet");
headerTable = new DataTable("ClientHeaders");
DataColumn newColumn = new DataColumn("ClientHeader", typeof(string));
headerTable.Columns.Add(newColumn);
newColumn = new DataColumn("StandardHeader", typeof(string));
headerTable.Columns.Add(newColumn);
DataRow newRow = null;
foreach (string s in headerLine.Split(','))
{
newRow = headerTable.NewRow();
newRow[0] = s;
newRow[1] = "Property";
headerTable.Rows.Add(newRow);
}
headerDataSet.Tables.Add(headerTable);
DataGridViewComboBoxColumn cbCol =
this.dataGridView1.Columns["standardColumn"] as DataGridViewComboBoxColumn;
cbCol.DataSource = this.standardList;
this.dataGridView1.AutoGenerateColumns = false;
this.dataGridView1.Columns[0].DataPropertyName = "ClientHeader";
this.dataGridView1.Columns[1].DataPropertyName = "StandardHeader";
this.dataGridView1.DataSource = headerDataSet;
this.dataGridView1.DataMember = "ClientHeaders";
}
private void btnGetValue_Click(object sender, EventArgs e)
{
this.headers = this.MakeHeaderDictionary();
this.MappingForm.HeaderDictionary = this.headers;
this.MappingForm.DataFile = this.dataFile;
this.MappingForm.FormClosing += new FormClosingEventHandler(MappingForm_Closed);
this.MappingForm.Show();
}
void MappingForm_Closed(object sender, FormClosingEventArgs e)
{
this.docsDictionary = this.MappingForm.DocumentsDictionary;
this.ProcessMods();
}
}
Code for second form follows
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Code for second form.
public partial class MappingForm : Form
{
List<string> standardDocumentList = new List<string>();
FieldMappingDictionary documentsDictionary = new FieldMappingDictionary();
private Dictionary<string, string> headerDictionary = null;
private string dataFile;
public MappingForm()
{
InitializeComponent();
InitLookupLists();
}
private void InitLookupLists()
{
this.standardDocumentList.AddRange(new string[] { "Full", "Partial", "None" });
}
private void MappingForm_Load(object sender, EventArgs e)
{
DataGridView dgv = null;
string headerString = null;
foreach (string key in this.headerDictionary.Keys)
{
headerString = this.headerDictionary[key];
switch (key)
{
case "Documentation":
dgv = this.dgvDocumentation;
break;
case "Property":
dgv = null;
break;
case "Offer":
dgv = null;
break;
case "Figures":
dgv = null;
break;
case "Guarantee":
dgv = null;
break;
}
if (dgv != null)
{
this.FillDatagrid(headerString, dgv);
}
}
}
DataTable dFill = null;
private void FillDatagrid(string headerString, DataGridView dgv)
{
String comString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
Path.GetDirectoryName(Path.GetFullPath(this.dataFile)) + @";Extended Properties=""Text;HDR=YES;FMT=Delimited;IMEX=1\""";
String strSql = "SELECT DISTINCT " + headerString + " FROM [" + Path.GetFileName(this.dataFile) + "]";
using (OleDbConnection conCSV = new OleDbConnection(comString))
{
conCSV.Open();
OleDbCommand dbCommand = new OleDbCommand(strSql, conCSV);
OleDbDataAdapter dAdapter = new OleDbDataAdapter(dbCommand);
dFill = new DataTable();
dAdapter.Fill(dFill);
}
bindingSource1.DataSource = dFill;
dgv.DataSource = bindingSource1;
DataGridViewComboBoxColumn lookupColumn = new DataGridViewComboBoxColumn();
this.dgvDocumentation.Columns.Add(lookupColumn);
lookupColumn.ValueType = typeof(string);
lookupColumn.HeaderText = "Standard";
lookupColumn.DataSource = this.standardDocumentList;
for (int i = 0; i < dgv.Columns.Count; i++)
{
dgv.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
dgv.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
}
}
private void CreateDocsDictionary()
{
foreach (DataGridViewRow row in this.dgvDocumentation.Rows)
{
if (row.Cells[0].Value != null)
{
this.documentsDictionary.Add(row.Cells[1].Value.ToString(), row.Cells[0].Value.ToString());
}
}
}
#region MappingForm PROPERTIES ...............................
public Dictionary<string, string> HeaderDictionary
{
get
{
return this.headerDictionary;
}
set
{
this.headerDictionary = value;
}
}
public string DataFile
{
get
{
return this.dataFile;
}
set
{
this.dataFile = value;
}
}
public FieldMappingDictionary DocumentsDictionary
{
get
{
return this.documentsDictionary;
}
}
#endregion MappingForm PROPERTIES
private void btnOK_Click(object sender, EventArgs e)
{
this.CreateDocsDictionary();
this.Close();
}
}
One more to come
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
public class FieldMappingDictionary : Dictionary<string, List<string>>
{
public void Add(string key, string value)
{
if (base.Keys.Contains(key))
{
if (!base[key].Contains(value))
{
base[key].Add(value);
}
}
else
{
List<string> list = new List<string>();
list.Add(value);
base.Add(key, list);
}
}
}
This is just a collection used in the demo.
Look forward to hearing from you.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
Hi Henry, have a good weekend?
I copied the code into two forms but I'm getting an error in the collection code you sent over. The errors I'm getting are:
1. expected {
2. Invalid token '>' in class, struct, or interface member declaration.
The error occurs at:
public class FieldMappingDictionary : Dictionary>
I placed this code outside the public partial class ListEditorForm : Form. Should I place this code somewhere else?
Also, looks like I have a couple of things coming down the pipe today so I may be fairly busy today. Just want you to know incase you don't hear back from me until later today.
Thank you,
Brenton
Brenton
|
|
|
|
|
Yes thanks, very restful.
I am a silly boy.
The errors are because in the reply box if you paste a < the editor replaces it with the html equivalent and the same with >.
If you replace all the '& gt;' with > and '& lt;' with <. all should be well.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Sorry Henry,
That is what I have and is giving the error. There are no '& gt;' or '& lt;' in the code. That must have happend when I copied and paste it into the reply. The error is occuring at public class FieldMappingDictionary : Dictionary>. I tried Dictionary <string, string> but it didn't work.
|
|
|
|
|
Here it is again.
This time I'll try to paste it properly.
<pre>
public class FieldMappingDictionary : Dictionary<string, List<string>>
{
public void Add(string key, string value)
{
// if the key is already in the list
if (base.Keys.Contains(key))
{
// only do it if not already there
if (!base[key].Contains(value))
{
// add the new value
base[key].Add(value);
}
}
else
{
// if the key ain't there, add it and a new values list
List<string> list = new List<string>();
list.Add(value);
base.Add(key, list);
}
}
}
</pre>
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Henry,
Almost there! I have one more problem. I am getting the error:
'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>.KeyCollection' does not contain a definition for 'Contains'
This occurs on line 6:
if (base.Keys.Contains(key))
|
|
|
|
|
I keep forgetting that you are using VS2005.
Slight modification:
<pre>
public class FieldMappingDictionary : Dictionary<string, List<string>>
{
public void Add(string key, string value)
{
// if the key is already in the list
if (this.KeysContains(key)) // <================= Modified Line
{
// only do it if not already there
if (!base[key].Contains(value))
{
// add the new value
base[key].Add(value);
}
}
else
{
// if the key ain't there, add it and a new values list
List<string> list = new List<string>();
list.Add(value);
base.Add(key, list);
}
}
public bool KeysContains(string key) // <=========== New Method, just iterates over keys collection, returns true if found
{
bool result = false;
foreach (string s in base.Keys)
{
if (s == key)
{
result = true;
break;
}
}
return result;
}
}
</pre>
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Incidentally I keep forgetting this.
You could save one step in your overall scheme, if loading the modified data into Excel is not a requirement.
SSIS can read XML directly, and both DataSet and DataTable have a method called WriteXML, which believe it, or not, writes their data (and/or schema) to an XML file.
As I said, if the Excel step is not a requirement, simply write the data to an XML file ready for SSIS.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Henry,
Looks like I have added all the code I need and the code compiles without warnings but the dgv doesn't get populated. I belive the only place I needed to add code too is here. If I am wrong then please advise further.
private void ProcessMods()
{
// Create a copy of original table structure with
// standardized column names**
// load original file data into it
// then do a series of updates using the docsDictionary, and the
// other Dictionaries
// STEP THROUGH THIS TO WATCH UPDATE STATEMENT BUILDING
StringBuilder selectBuilder = null;
foreach (string key in this.docsDictionary.Keys)
{
foreach (string val in this.docsDictionary[key])
{
selectBuilder = new StringBuilder();
selectBuilder.Append("UPDATE TestData SET Documentation = ");
selectBuilder.Append(key);
selectBuilder.Append(" WHERE Documentation = ");
selectBuilder.Append(val);
string updateQuery = selectBuilder.ToString();
// execute the query here
// you know OleDbConnection, OleDbcommand etc.
// then go round for next mod
//This is where I added the connection
DataTable dFill = null;
String comString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName(Path.GetFullPath(this.dataFile)) + @";Extended Properties=""Text;HDR=YES;FMT=Delimited;IMEX=1\""";
using (OleDbConnection conCSV = new OleDbConnection(comString))
{
conCSV.Open();
OleDbCommand dbCommand = new OleDbCommand(updateQuery, conCSV);
OleDbDataAdapter dAdapter = new OleDbDataAdapter(dbCommand);
dFill = new DataTable();
dAdapter.Fill(dFill);
}
bindingSource1.DataSource = dFill;
dataGridView1.DataSource = bindingSource1;
}
// go round for next key
}
// then do same for next dictionary
}
Do I need to add code for a ShowDialog and capture the full path of the file? Also, the test file is in the debug folder. Maybe it would be easier to hardcode the path of the file in the com string. What do you think?
Thank you,
Brenton
modified on Wednesday, May 27, 2009 11:50 AM
|
|
|
|
|
Strictly speaking ProcessMods() was intended merely, to create a copy of the table containing client-data but with your standard column names (See the comments at start of the method). I have left that bit for you to do as I am not sure about the best method for that process. Then it should process all the updates retrieved from MappingForm. You could fill the grid during that operation, but it would slow it down enormously, although it would show progress.
The alternative would be to show the modifications after they are completed. In which case your dgv filling code should either be the very last thing in ProcessMods() , or immediately after the call to ProcessMods() in the MappingForm_Closed event handler (this would be my preference).
For ProcessMods() the parts left to be done are, as mentioned above, copying the data to a new table with proper column names (incidentally I suggested copying so that the original data remains intact, in case of accidents. ), and this bit:
which is immediately above your new dgv fill code.
bwood2020 wrote: Do I need to add code for a ShowDialog and capture the full path of the file?
Yes, for the production version, you probably would. Putting the test data in the debug folder was simply for convenience for what is a demo of a concept.
If you stepped through the query building bit, I hope that you could see that for each of your standardised pieces of data the method builds an update query for each of the versions the client has used. It might turn out that using a query is not the best way to perform this operation, but the point of the exercise is to show that the data required to do the mods, is in a format which will enable the changes to be done fairly easily.
I am currently looking at methods for copying the client data into a table with standard column names.
I'll be back with you shortly. Of course, if you already know how to do this, let me know.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Just when you thought it was safe to .........
Some mods to the first form, I am posting the whole thing, because there are some renames, as well as some new methods and fields:
List<string> standardList = new List<string>();
Dictionary<string, string> clientHeaders = new Dictionary<string, string>();
Dictionary<string, string> standardHeaders = new Dictionary<string, string>();
DataSet testDataSet = null;
DataTable headerTable = null;
DataTable clientDataTable = null;
DataTable standardDataTable = null;
MappingForm mappingForm = null;
readonly string dataFile = "TestData.csv";
FieldMappingDictionary docsDictionary = null;
public ListEditorForm()
{
InitializeComponent();
InitStandardList();
}
private void InitStandardList()
{
standardList.AddRange(new string[] { "Property", "Offer", "Documentation", "Figures", "Guarantee" });
}
private void ProcessMods()
{
this.GetClientData();
this.CreateStandardTable();
foreach (string key in this.docsDictionary.Keys)
{
foreach (string val in this.docsDictionary[key])
{
foreach (DataRow row in this.standardDataTable.Rows)
{
if (row["Documentation"].ToString() == val)
{
row["Documentation"] = key;
}
}
}
}
}
private void MakeHeaderDictionaries()
{
this.clientHeaders = this.MakeHeaderDictionary();
this.standardHeaders = this.MakeStandardHeaderDictionary();
}
private Dictionary<string, string> MakeStandardHeaderDictionary()
{
Dictionary<string, string> result = new Dictionary<string, string>();
foreach (DataRow row in this.headerTable.Rows)
{
result.Add(row[0].ToString().Trim(), row[1].ToString().Trim());
}
return result;
}
private Dictionary<string, string> MakeHeaderDictionary()
{
Dictionary<string, string> result = new Dictionary<string, string>();
foreach (DataRow row in this.headerTable.Rows)
{
result.Add(row[1].ToString().Trim(), row[0].ToString().Trim());
}
return result;
}
private void GetClientData()
{
String comString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
Path.GetDirectoryName(Path.GetFullPath(this.dataFile)) + @";Extended Properties=""Text;HDR=YES;FMT=Delimited;IMEX=1\""";
String strSql = "SELECT * FROM [" + Path.GetFileName(this.dataFile) + "]";
using (OleDbConnection conCSV = new OleDbConnection(comString))
{
conCSV.Open();
OleDbCommand dbCommand = new OleDbCommand(strSql, conCSV);
OleDbDataAdapter dAdapter = new OleDbDataAdapter(dbCommand);
clientDataTable = new DataTable("ClientData");
dAdapter.Fill(clientDataTable);
this.testDataSet.Tables.Add(clientDataTable);
}
}
private void CreateStandardTable()
{
this.standardDataTable = this.clientDataTable.Copy();
this.standardDataTable.TableName = "StandardData";
for (int i = 0; i < this.standardDataTable.Columns.Count; i++)
{
this.standardDataTable.Columns[i].ColumnName =
this.standardHeaders[this.clientDataTable.Columns[i].ColumnName.Trim()];
}
this.testDataSet.Tables.Add(standardDataTable);
}
#region ListEditorForm PROPERTIES ...............................
public Dictionary<string, string> ClientHeaders
{
get
{
return this.clientHeaders;
}
private set
{
this.clientHeaders = value;
}
}
public Dictionary<string, string> StandardHeaders
{
get
{
return this.standardHeaders;
}
private set
{
this.standardHeaders = value;
}
}
private MappingForm MappingForm
{
get
{
if (this.mappingForm == null)
{
this.mappingForm = new MappingForm();
}
return this.mappingForm;
}
}
#endregion ListEditorForm PROPERTIES
private void ListEditorForm_Load(object sender, EventArgs e)
{
string headerLine;
using (StreamReader sr = new StreamReader(dataFile))
{
headerLine = sr.ReadLine();
}
testDataSet = new DataSet("HeaderDataSet");
headerTable = new DataTable("ClientHeaders");
DataColumn newColumn = new DataColumn("ClientHeader", typeof(string));
headerTable.Columns.Add(newColumn);
newColumn = new DataColumn("StandardHeader", typeof(string));
headerTable.Columns.Add(newColumn);
DataRow newRow = null;
foreach (string s in headerLine.Split(','))
{
newRow = headerTable.NewRow();
newRow[0] = s;
newRow[1] = "Property";
headerTable.Rows.Add(newRow);
}
testDataSet.Tables.Add(headerTable);
DataGridViewComboBoxColumn cbCol =
this.dataGridView1.Columns["standardColumn"] as DataGridViewComboBoxColumn;
cbCol.DataSource = this.standardList;
this.dataGridView1.AutoGenerateColumns = false;
this.dataGridView1.Columns[0].DataPropertyName = "ClientHeader";
this.dataGridView1.Columns[1].DataPropertyName = "StandardHeader";
this.dataGridView1.DataSource = testDataSet;
this.dataGridView1.DataMember = "ClientHeaders";
}
private void btnGetValue_Click(object sender, EventArgs e)
{
this.MakeHeaderDictionaries();
this.MappingForm.HeaderDictionary = this.clientHeaders;
this.MappingForm.DataFile = this.dataFile;
this.MappingForm.FormClosing += new FormClosingEventHandler(MappingForm_Closed);
this.MappingForm.Show();
}
void MappingForm_Closed(object sender, FormClosingEventArgs e)
{
this.docsDictionary = this.MappingForm.DocumentsDictionary;
this.ProcessMods();
this.testDataSet.Tables["StandardData"].WriteXml("TestData.xml", XmlWriteMode.WriteSchema);
}
}
There are no changes to MappingForm, at this time.
TestData.xml will be in the debug directory. When examining it you must remember that the code, as is, only corrects the 'Documentation' column.
I also found out why the FieldMappingDictionary gave you errors the first time, here is the corrected version:
public class FieldMappingDictionary : Dictionary<string, List<string>>
{
public void Add(string key, string value)
{
if (base.ContainsKey(key))
{
if (!base[key].Contains(value))
{
base[key].Add(value);
}
}
else
{
List<string> list = new List<string>();
list.Add(value);
base.Add(key, list);
}
}
}
Let me know what you think. Be gentle with me.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
If I had more than two brain cells to rub together, I would have written this:
void MappingForm_Closed(object sender, FormClosingEventArgs e)
{
this.docsDictionary = this.MappingForm.DocumentsDictionary;
this.ProcessMods();
this.testDataSet.Tables["ClientData"].WriteXml("ClientTestData.xml", XmlWriteMode.WriteSchema);
this.testDataSet.Tables["StandardData"].WriteXml("StandardTestData.xml", XmlWriteMode.WriteSchema);
}
This should make it easier to compare unmodified and modified data. You should also note that the column names have been modified in the StandardTestData.xml version.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry,
This is great! Very well organized and I like the idea of having the ability to contain the integrity of the original data set. I also like the idea of outputting to an xml file as well as comparing both the original data set to the standardized data set.
I did have to modify some of the code you sent over. I had to add <string> to List and <string, string> to the Dictionaries. Let me know if this is not correct and I will go back through and make the recommended changes.
I'm still having problems populating the dgv on form 1. Maybe it's that I have not added some functionality to it. On Form 1 I added a dgv and a button name dataGridView1 and btnGetValue. On Form 2 I added a dgv and a button named dgvDocumentation and btnOK. Am I forgetting anything? I have read through the code and it compiles but just can't pinpoint what's going on.
You’re the man Henry!!!
|
|
|
|
|
bwood2020 wrote: I'm still having problems populating the dgv on form 1. Maybe it's that I have not added some functionality to it. On Form 1 I added a dgv and a button name dataGridView1 and btnGetValue. On Form 2 I added a dgv and a button named dgvDocumentation and btnOK. Am I forgetting anything? I have read through the code and it compiles but just can't pinpoint what's going on.
That sounds right.
I'll go through my designer code to see if I've forgotten to tell you something obvious.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Er..................
I did tell you that I had added two dgv columns, in the designer, didn't I?
No, you say!
ahem:
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.btnGetValue = new System.Windows.Forms.Button();
this.clientColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.standardColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
this.headersBindingSource = new System.Windows.Forms.BindingSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.headersBindingSource)).BeginInit();
this.SuspendLayout();
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.clientColumn,
this.standardColumn});
this.dataGridView1.Location = new System.Drawing.Point(12, 12);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.Size = new System.Drawing.Size(284, 171);
this.dataGridView1.TabIndex = 0;
this.btnGetValue.Location = new System.Drawing.Point(154, 236);
this.btnGetValue.Name = "btnGetValue";
this.btnGetValue.Size = new System.Drawing.Size(75, 23);
this.btnGetValue.TabIndex = 1;
this.btnGetValue.Text = "Value";
this.btnGetValue.UseVisualStyleBackColor = true;
this.btnGetValue.Click += new System.EventHandler(this.btnGetValue_Click);
this.clientColumn.HeaderText = "Client Header";
this.clientColumn.Name = "clientColumn";
this.standardColumn.HeaderText = "Standard Header";
this.standardColumn.Name = "standardColumn";
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 14F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(422, 288);
this.Controls.Add(this.btnGetValue);
this.Controls.Add(this.dataGridView1);
this.Name = "ListEditorForm";
this.Text = "List Editor";
this.Load += new System.EventHandler(this.ListEditorForm_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.headersBindingSource)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.Button btnGetValue;
private System.Windows.Forms.BindingSource headersBindingSource;
private System.Windows.Forms.DataGridViewTextBoxColumn clientColumn;
private System.Windows.Forms.DataGridViewComboBoxColumn standardColumn;
Here is the designer code for the first form. Just replace the code in your form1.designer.cs file with it.
I think I'll go for a lie down in a dark room now.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Ha-ha, you have a very good sense of humor. It makes it more fun and adds to my dull and busy day. You are correct sir. You did have that. I am looking through Form 2 and I see I need to add something else to get this to work. One down and one to go. I will follow up with you tomorrow. Thanks again Henry and have a good night!
|
|
|
|
|
Hi Henry,
I was extremely busy yesterday but I was able to work on this demo for about an hour. As it turns out I am having difficulties getting the second form to work. I looked through the code again and saw that I was missing a combobox so I added that to the dgv; however this didn't fix the issue. Can you send the designer code for the second form when you get a chance please?
Thank you,
Brenton
|
|
|
|
|
Hi Henry,
Thank you for sending me the demo. Even though I was not able to get it to work, I was able to get my app working by dissecting the code you wrote. I'm sorry I caused you frustration and thank you again for helping me on this. I will close this out now and give you the rating you deserve.
Thanks again,
Brenton
|
|
|
|
|
Hello.
I have a application with a webclient. In that webclient I am loading a homepage with about 5 frames, but one of the frames are refreshing constantly each 30second.
That gives me problem when I want to use the source from another frame - because when I use IsBusy and it is refreshing the frame with constantly refreshing while I am navigating another frame, does the application think that frame is done navigating too, and then I of course get an error.
It happens very often, and stops the whole program.
So is there any way only to check one frame if it is done loading ?
Hope your guys can help me out.
|
|
|
|
|
hello,
i am using the WebBrowser Navigate to navigate to a webpage from my c# application.
i try to post data to a form which is in that page. (its my page , i control it)
first , what is the name of the field i need to put in the post string?
is it ID or NAME ?
second , i tried various methods but none filled the form textbox with the information i sent. what am i doing wrong?
here's the c# code
WebBrowser Web = new WebBrowser();
string postdata = "ctl00_pass=1234";
System.Text.Encoding a = System.Text.Encoding.UTF8;
byte[] SendBytes = a.GetBytes(postdata);
Web.Navigate(WebBase + WebAddress, WebTitle, SendBytes, "Content-Type: application/x-www-form-urlencoded");
.
and here's the website
&lt;form name="aspnetForm" method="post" action="default.aspx?key=5555" id="aspnetForm"&gt;
&lt;input name="ctl00$pass" type="text" id="ctl00_pass" /&gt;
</form>
.
tnx
|
|
|
|
|