By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,876 Members | 1,206 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,876 IT Pros & Developers. It's quick & easy.

Adding row to DataGrid

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.