472,792 Members | 4,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,792 software developers and data experts.

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
0 1601

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jim | last post by:
In my Win App, I have a datagrid that's bound to a dataset. When the form loads, the datagrid fills. How can I add an empty row to the end of the datagrid during a button click (similar to...
2
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete...
5
by: Phil Townsend | last post by:
I need to add a button to a datagrid. I have tried using the ButtonColumn and have also tried adding a button to a templatecolumn > itemtemplate. Whatever I have tried doesn't work, nor does it...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
1
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
2
by: Praveen Balanagendra via .NET 247 | last post by:
here is the source code private void AddRow() { TableCell tc = new TableCell(); tc.Controls.Add(new LiteralControl("NewRow")); DataGridItem di = new...
2
by: Bob Hollness | last post by:
Hi group. I am a newbie to ASP.NET as you will see from some of the questions I may ask! I have a datagrid which I have populated from a database. It works great! I have added a column, via...
3
by: Fao, Sean | last post by:
I have a DataGrid that I'm adding CheckBox controls to at runtime (in the code behind) and I'm not sure if I'm doing it correctly. First of all, I noticed that the MyDataGrid.Columns.Add() method...
2
by: Flack | last post by:
Hey guys, I have a DataGrid and DataTable field in my class : private ImageDataGrid dataGrid1; //ImageDataGrid extends dataGrid and just overides OnMouseDown private DataTable dt = new...
1
by: Tor Inge Rislaa | last post by:
Adding HTML tags to data from SQL server When dragging a table on to a web form in an ASP.NET 2.0 application, the connection is established and the data is displayed in a DataGrid. Is it...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.