467,080 Members | 909 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,080 developers. It's quick & easy.

Adding row to DataGrid

I am experiencing a problem when I add a row to a DataTable that is
used on a DataGrid in my Windows Form application. When I add a new
row I no longer get a response from my form. I see the row apear in the
DataGrid but still no response from the form. If I add the same data
to a rich text box and don't use the datagrid I don't have this
problem. What am I missing? It has to be something simple. Here is
my code snipet:

private void AddMessage(byte[] Data)
{
string Msg = ascii.GetString(Data); // Converts byte array of ascii
characters to string
int LessLoc = Msg.IndexOf("<", 0 , 1);// Should be first character
int GreaterLoc = Msg.IndexOf(">", 0, 5); //Can't be more than 5
characters into the message

if ((LessLoc > -1) && (GreaterLoc > 0))
{
string[] FSCombo =
FacilitySeverity(Convert.ToInt32(Msg.Substring(Les sLoc+1,
(GreaterLoc-LessLoc)-1)));

if ((FSCombo[0] != null) && (FSCombo[1] != null))
// rtxMsgs.Text += FSCombo[0] + ":" + FSCombo[1] + " - " +
Msg.Substring(GreaterLoc+1) + "\n";
SyslogTable.Rows.Add(new string[] {FSCombo[0], FSCombo[1],
Msg.Substring(GreaterLoc+1)} );
else
// rtxMsgs.Text += Msg + "\n";
SyslogTable.Rows.Add(new string[] {"", "", Msg.Substring(GreaterLoc+1)}
);
}
}

Here is how the DataGrid is setup:
this.dataGrid.CaptionVisible = false;
this.dataGrid.CausesValidation = false;
this.dataGrid.DataMember = "";
this.dataGrid.DataSource = this.SyslogTable;
this.dataGrid.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGrid.Enabled = false;
this.dataGrid.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGrid.Location = new System.Drawing.Point(0, 0);
this.dataGrid.Name = "dataGrid";
this.dataGrid.ReadOnly = true;
this.dataGrid.RowHeadersVisible = false;
this.dataGrid.Size = new System.Drawing.Size(808, 373);
this.dataGrid.TabIndex = 1;
this.dataGrid.TableStyles.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
this.dataGridTableStyle1});

this.SyslogTable.Columns.AddRange(new System.Data.DataColumn[] {
this.dataColumnFacility,
this.dataColumnSeverity,
this.dataColumnMessage});
this.SyslogTable.TableName = "SyslogTable";

Thanks for the help!
--Mark

Nov 17 '05 #1
  • viewed: 1383
Share:

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Clayton Hamilton | last post: by
5 posts views Thread by Phil Townsend | last post: by
3 posts views Thread by Jim Heavey | last post: by
2 posts views Thread by Bob Hollness | last post: by
3 posts views Thread by Fao, Sean | last post: by
2 posts views Thread by Flack | last post: by
1 post views Thread by Tor Inge Rislaa | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.