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