|
Modify your class form2 to contain
public RichTextBox MyRichTextBox
{
get {
return richTextBox1;
}
} and use f2.MyRichTextBox instead of f2.Controls[0] .
And by the way "its didnt worked" is not helpful at all - if you don't tell us what the problem/error message is exactly we cannot help you.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Thanks but...its not working...
Here is some more information ...Can u please help me...?
<br />
<br />
<br />
public SerialPort comport = new SerialPort();<br />
<br />
public Form f1;<br />
<br />
f1 = new ChildForm();<br />
f1.MdiParent = this;<br />
<br />
comport.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);<br />
<br />
<br />
private void btn_Senddata_Click(object sender, EventArgs e)<br />
{<br />
comport.open();<br />
comport.Write("This is the text to be transmitted");<br />
<br />
}<br />
<br />
public void port_DataReceived(object sender, SerialDataReceivedEventArgs e)<br />
{<br />
string ReceivedData = comport.ReadExisting();<br />
<br />
ReceiveLog(LogMsgType.Incoming, ReceivedData);<br />
<br />
if(f1.Controls[0].InvokeRequired)<br />
{<br />
f1.Controls[0].Invoke(new EventHandler(delegate<br />
{ f1.Controls[0].AppendText(ReceivedData); <br />
}));<br />
}<br />
<br />
<br />
<br />
<br />
<br />
RichTextBox MyRichTextBox = new RichTextBox();
<br />
<br />
<br />
<br />
What is the problem,i am not able to understand...
Thanks,
Vinay
|
|
|
|
|
Once again: Please read the error messages you get and try to understand them.
If you don't understand them, post them here so that we can help you!
With the code snipplet you posted I think the problem could be that you declared f1 as Form but in fact it's an instance of ChildForm .
The class ChildForm does have a public RichTextBox named MyRichTextBox , the class Form doesn't.
So to get your code to work you should change public Form f1; to public ChildForm f1; and your DataReceived event handler should read
string ReceivedData = comport.ReadExisting();
ReceiveLog(LogMsgType.Incoming, ReceivedData);
if(f1.MyRichTextBox.InvokeRequired)
{
this.Invoke(new EventHandler(delegate
{ f1.MyRichTextBox.AppendText(ReceivedData); }
));
} else {
f1.MyRichTextBox.AppendText(ReceivedData);
}
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
I am designing a workflow for SPS2007.In this i am creating six task by workflow.I got problem when I want to use InfoPath form, in Task Edit form in Task List.
Also I want to open All the detials of Six task created in Single Form and want to edit that InfoPath form.
bharat sukhwal
|
|
|
|
|
Hi All,
I have a compeleted project that uses ms access database and some images and crystal reports, how can I make an installation file (Setup file). concerning the directory path for db file. Also, in crystal reports I had to specify the db file path in side the code. I tried the built in component in VS2005 but I couldn't.
Very Urgent, Could any one help
|
|
|
|
|
You may set the db connection of Crystal Reports in code.
I used CrystalReport before, but I don't have these sample code at home.
Please get this from MSDN.
hoping this help.
|
|
|
|
|
I am replying for what i got to know about your unclear statements, i guess your problem is that when u install some application, then it doesnt find it resources like images,icons, bitmaps after installation, well mate.. for that while making setup file, Include them in a wizard and then include this line
AppDomain.CurrentDomain.BaseDirectory
it will refer to the current installation directry or from where the exe is being run
enjoy !
if u face any problem do contact me
|
|
|
|
|
Thank realin for your reply,
This is a part of my code in the report viewer:
-----------------------------------------
int slach = Application.ExecutablePath.LastIndexOf('\\');
string dbLocation = Application.ExecutablePath.Substring(0, slach) + "\\Database\\hall.mdb";
ReportOkRes1.DataSourceConnections[0].SetConnection(dbLocation, dbLocation, false);
-----------------------------------------
It works fine in VS2005 but when I do the Setup project, and do the installation the application didn't work. I am sure that the problem is in reading from the db file "It does not find it".
|
|
|
|
|
Im a begining C# programmer and was hoping you guys could help me. Im working on my first real project and I am a little confused on how exactly to set it
up. I've read so many articles on this, but they all seem to be saying different things. Here is a psuedo code example of my current setup:
class EmployeeDA<br />
{<br />
public void Insert(Employee emp)<br />
{<br />
}<br />
}<br />
<br />
class Employee<br />
{<br />
private int id;<br />
private string name;<br />
private EmployeeDA = new EmployeeDA();<br />
<br />
public void Insert()<br />
{<br />
EmployeeDA.Insert(this);<br />
}<br />
}<br />
<br />
class Employees : List<Employee><br />
{<br />
public void AddEmployeesToTable()<br />
{<br />
foreach(Employee emp in this)<br />
emp.Insert;<br />
}<br />
}
Is this correct? I know there are many different ways to do it, so maybe "correct" isnt the right word. I guess what I want to know is if there is a "better" way of doing it. Are there any glaring issues with the way I am doing it currently?
Thanks
|
|
|
|
|
I think the architecture must depend on the project design.
If your project is not a complicated one, may be two layers would be a better one. I mean 'the data layer' and 'the business layer'.
|
|
|
|
|
Hi
As you mentioned there is no correct architecture.When you are designing a solution you should consider the domain of the problem that you are solving.
There are lots of patterns that you can choose from ( for example Data Access Objects and Active record)
If you are working on a small project ( and you don't expect it to become a large application in future) you can mix up the Data Access and the business layer or if you prefer you can have both in your project (It's not very hard to split them afterwards)
Be careful not to mix up your user interface layer with your business layer since it's very hard to refactor them afterwards.
Take a look at Martin Fowler's articles at his site (www.matinfowler.com)
and specially take a look at his Enterprise patterns.
Good Luck
|
|
|
|
|
Ok first off, I am very new to all of this C# stuff - so be gentle.
I have a windows form with a simple table . I am not using the data grid. but just displaying one record at a time.
I want to be able to determine which row of data I am currently viewing in the form and how to programatically change that row to display another.
For instance If the user clicks on a Search Button, it will take them to a modal form which will allow them to select a record and return the Key Value to the calling form, and select that row to display on the form.
Have searched now for days but am no closer to the answer.
John Martin
|
|
|
|
|
Hi
As far as I know a data table is not a cursor (but as its name says is a table or at least a snapshot of a table) then there's no current row when you are working with a table.
If you like to find a row within a table you can use its defualt data view and use its Find method which has some overloads.
(for example myTable.DefualtView.Find(key))
You can have a local variable that works as a bookmark and shows the current row index then you can retrieve current row using DataTabe.Rows indexer for example
int currentRow=1;
DataRow row=myTable.Rows[currentRow];
then you can implement some methos to navigate through your data table (currentRow+=1,currentRow-=1)
Good Luck
|
|
|
|
|
mmm
It seems that I know even less than I thought.
I have tried looking at this from all angles - to no avail.
Let's say that you are using the customer table in the Northwind DataBase.
You add a new customer. That customer is appended to the end of the table.
But I want to refresh the dataSet so that it is :
a. In Alphabetical order again. - this I can do. But it takes the focus back to the first row in the Data Set.
B. The row that is displayed on the form is the row that I have just added. "Eg Smith" and the next button will then display the row that follows Smith.
It is this latter aspect that I find hard to accomplish. If I can do this, then I feel certain that I can do the rest of what I want.
Any specific clues on this would be greatly appreciated.
John Martin
|
|
|
|
|
Hi
You can hold the key of a new row that has been added and set your current row to this new row (using sort and find metohd)
if you sort your table using its default view property (myTable.DefaultView.Sort="Field1 DESC,Field2"; ) then the next button will show the next record according to sorted key.
But I have a question to ask, if there's only one record showing to user each time , why do you load all the data to a data table ? you can load a record whenever it's needed.
for example if you have a code field that you want to use as your sort key you can get the next record using :
<br />
SELECT TOP 1 * FROM myTable WHERE code>@currentCode ORDER BY CODE<br />
and you can get the previous record using :
<br />
SELECT TOP 1 * FROM myTable WHERE code<@currentCode ORDER BY CODE DESC<br />
Getting the first and last records is also very easy.
<br />
SELECT TOP 1 * FROM myTable ORDER BY Code
SELECT TOP 1 * FROM myTable ORDER BY Code DESC
<br />
The good news is that you can find your record before loading it to your app thus only the needed data is loaded.
Regrads
|
|
|
|
|
Hi again and thanks for your input.
The points you make about using seperate select statements is a good one.
I also tried the first method and your suggestions are good. With the find method indeed finds the row index. but how do I get the form to display the contents of the row that I have "Found" - for instance I may be looking at the first row of Customers. I want to look for the Row that has an CustomerID of "SMITH". IF I do a find in it - it will return a value that gives me the row index of the DefaultView, but how do I move the focus to that row so that is the row that is displayed?
Again thanks for all your help
jm
John Martin
|
|
|
|
|
Hi,
I have found a few (4+) bugs in VS2005 C# that I worked around and I seem to have found another that I can't workaround ( but can drop if I really want/need to ).
Can I have some feedback on the pro's and con's of installing the beta SP1 please.
Thanks,
Glen Harvy
|
|
|
|
|
please provide your Feedback directly to MS on connect
'A programmer is just a tool which converts caffeine into code'
|
|
|
|
|
You might be aware that whenever the user clicks on the column header of a filled data grid view, the rows of the data grid view or sorted according to that column values.
How can i prevent this. I don't want the user to be able to sort the values.
|
|
|
|
|
just use the following code
for (int i = 0; i < dataGridView1.Columns.Count; i++)
{
dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
}
Hope that works for u...
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Just what i wanted.
Thanks a lot Pramod. It worked.
|
|
|
|
|
Tearing my hair out here.
I remember seeing an artical using the .net 2.0 WebBrowser combined with a tree control to decompose a web page or view xml conversion results in a tree.
Been looking all day stumbling across lots of other stuff that I book marked.
Thanks
|
|
|
|
|
Hello everyone!
OK, I need to write and read integers on a file... What's the best way to do this in C#? Thanks!
Windows Calculator told me I will die at 28.
|
|
|
|
|
Your subject talks about a specific way of doing this. Is that the exact way that you want to do it? Or would using a BinaryWriter be ok?
---
b { font-weight: normal; }
|
|
|
|
|
Hmm... Didn't know about that class! Thanks!
Windows Calculator told me I will die at 28.
|
|
|
|