|
Hi !
How to embedding an Access table into datagrid (C#). After input data in datagrid, then click button save, it's will insert data on datagrid into Access database.
Thanks!
|
|
|
|
|
Just use a datagrid. After data is input, then you need to code the saving code on the save button. Not much else we can help you with since you did not give any real information about database schema, etc.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I'm busy on a record layout editor for flat file exports. I have a 'preview' window where the user can view a sample of the expected output, the sample being one line for each record type in each grouping. I would like to allow the user to scroll each line left and right, but independently, and would like suggestions on how to achieve this.
I think to keep it simple, I can use a fixed width font and manage a collection of start and end columns for each displayed line, then just render to a textbox the visible portions of each line. Getting more complicated, I could use a lightweight textbox for each line, with an 'invisible horizontal scrollbar', but unless it's as easy as it looks, I think I would be heading down a long, dark path there.
Any other suggestions?
|
|
|
|
|
Hi,
in order to show line oriented text I tend to prefer a ListBox.
If you choose a UserDrawn DrawMode, and implement DrawItem event handler, you could have
each line scroll the way you like.
IMO it is not necessary to select a non-proportional font (although I often do).
Not sure though how you would control the scroll amount...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thank you Luc!
You've given me an inspiration that took a few hours to crystallise. I can get the best of both worlds by using a ListBox for my basic line editing, and implement my own character based scrolling. As all my exports are text files, I don't need more than character scrolling for full WSYIWYG.
|
|
|
|
|
You're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
You know I spend too much thought on solving business problems, that I lose touch with the technical sides of things. Just thinking about even character based scrolling is taxing my brain, and years ago I did so much of it from scratch. I suppose some block paper and scribblings will evoke a flood of DOS memories.
|
|
|
|
|
I see two ways to do character based scrolling:
1. without user drawing: just give a variable substring to the ListBox item
2. with user drawing: use a variable x position and paint the entire string, parts of it
will end up outside the drawing area resulting in a scroll effect
BTW: DOS memories will not suffice for .NET applications...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I'm going with #1 on this, but thanks for #2. I've never ventured into user drawing to draw anything, only to change colours.
|
|
|
|
|
I'm trying to get and set the state of multiple groups of radio buttons. Each group has 6 radiobuttons. I need to load and save the configuration of the groups- which one is checked. I've tried reading the Control->Item[i] in the panel, but do not see how to read which button is set or how to set it after reading a config file. The names of each can be read, but how can the Checked parameter be retrieved. Is there a way to get at that data without having to have a handler for each one and waiting for the stateChanged event?
|
|
|
|
|
Hi, this is how I handle groups of radio buttons:
1. design them all unchecked
2. assign them all (within one group) the same CheckedChanged handler
3. in the CheckedChanged handler, use "object sender" to identify the rb; store it somewhere
(maybe a class variable, maybe the Tag of the GroupBox,...)
4. in the form constructor or the Load handler: determine which rb needs to be checked,
and check it
5. in the form close handler: save the name of the currently selected rb (from the variable
or Tag in 3.)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks for the quick answer Luc.
What about loading the configuration later, after the constructor? I'm dealing with several hundred groups, and creating each of them individually is less than optimal. I'd like to store a radiobutton configuration in a config file (or several config files) and load them in on demand. I've been struggling trying to figure out how to set the Checked property through code after referencing the items through:
this->get_Controls()->get_Item(j)->get_Controls()->get_Item(i))
Item(j) is the group, Item(i) is the radioButton. Can the checked property can be set this way or similar? The order is the same for each group, so it's relatively easy to read the checked radioButton.
|
|
|
|
|
Hi Steve,
I trust it can.
You will have to cast to RadioButton before you can access the Checked property.
And I would prefer to split the line in two, one get_Item() per line seems more than enough
to me; I expect there too it will need a cast, don't know for sure what type get_Item returns,
if it is too general (such as object) it definitely needs a cast.
Read the documentation on that, and try it!
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks again Luc,
I got it to work. It will certainly make life a lot easier.
I created a ControlCollection to hold the get_Controls() and after checking to make sure the item is a radiobutton cast the item to a radiobutton and used set_Checked() to set its value. It works like a charm!
|
|
|
|
|
I did a windows forms application to print a queue using linkedlists in visual studio 2005 c++ language.
I want to display the job id,file name & priority in the list box.But i didn't get that output.I'm stuck in that point.I can't go beyond with out completing that point.
Also I want to know how to display above values in a data grid view when i click a button at the run time.I want to know the button click event codings for that task.(data grid view)
I have another button called "PAUSE" in my form.When i click that button i want to stop the printing of data in the list box.I used deletenode function in linkedlist for that task.But it don't works.I want to know the button click event for that button (pause) also.
I am pleased if u can reply me if you know the answers for the above problems
thanx.
|
|
|
|
|
Hi,
1. ListBox
this is what a ListBox shows:
- strings, if that is what you add to its Items collection
- ToString() results of whatever type you add to Items
- whatever you want if you do the painting yourself.
So you must:
(a) either construct a string that holds all the required information and at that to the
Items; you may want to choose a non-proportional font (e.g.Courier New), and
String.PadRight() or String.PadLeft() may help you in simulating a columnar layout
(b) or go for an "owner drawn" DrawMode, and use the relevant events (DrawItem, MeasureItem).
(b) is more complex than (a) !
2. DataGridView
showing the same thing in a DGV may require slightly more code, but the result will
show resizeable and sortable columns all by itself.
I suggest you read the DGV documentation and some CodeProject article on it. You can
and should use the Search facilities (on CodeProject or Google).
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
hi
I want to embed the Windows Media Player to my C# win app
I did it successfully.
and I know that for changing it's skin, have to use of 'IWMPRemoteMediaServices.GetCustomUIMode' method.
but I can not find this method at all.
I do not know how can select a desired skin for my WMP object in my application.
anybody help me ?!
H.R
|
|
|
|
|
You need to add a reference to the Windows Media Player API for this function to work.
Go to Project -> Add Reference..
Then click the COM tab and find Windows Media Player UI in the list, and click OK.
Virtual1ty "Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
thanks Virtual1ty ...
I have done this and I have relation with Windows Media Player
but 'IWMPRemoteMediaServices.GetCustomUIMode' method is not in the list.
bye
H.R
|
|
|
|
|
Then I can't help you, sorry.
I am not an expert on this field.
Virtual1ty "Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
I am trying to get the Combo Box working so that i can get the drop-down boxes available for the database columns to be placed in the DataGridView.
But i am getting the following error when the data displays in the DataGridView
The following exception occurred in the DataGridView:
System.ArgumentException: DataGridViewComboBoxCell value is not valid.
To replace this default dialog please handle the DataError event
Background:
The way i am selecting the 'Column Type' is through the Designer.
So i can choose the DataGridViewTextBoxColumn or DataGridViewComboBoxColumn
The dataGridView is hooked up to a bindingSource and I have my bindingSource wired to a List Object.
There is a dataTime picker control on the form, which is used to pull the data.
When i choose the DataGridViewTextBoxColumn, the data displays perfect.
But when i change the 'Column Type' to DataGridViewComboBoxColumn, running the form gives the error repeatedly and as i click on each error, one row of data displays and so on.
Does anyone have a suggestion?
|
|
|
|
|
This error occured when datagrid column value not match with combobox colloection items.this error can be handle on datagrid dataerror events.
void view_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
if (e.Exception.Message == "DataGridViewComboBoxCell value is not valid.")
{
object value = view.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
if (!((DataGridViewComboBoxColumn)view.Columns[e.ColumnIndex]).Items.Contains(value))
{
((DataGridViewComboBoxColumn)view.Columns[e.ColumnIndex]).Items.Add(value);
e.ThrowException = false;
}
}
}
Jitender Parnami
|
|
|
|
|
In C#.net You should handle data error event of the datagridview
private void grdGuestServiceDetail_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
if(e.Context== (DataGridViewDataErrorContexts.Formatting) || e.Context==(DataGridViewDataErrorContexts.PreferredSize))
{
e.ThrowException = false;
}
}
and In VB.net
Private Sub DataGridView_DataError(ByVal sender As Object, ByVal e As DataGridViewDataErrorEventArgs)
If (e.Context _
= (DataGridViewDataErrorContexts.Formatting Or DataGridViewDataErrorContexts.PreferredSize)) Then
e.ThrowException = false
End If
|
|
|
|
|
Hello
can someone tell me are there any APIs or something like that available so that I set my own custom theme in place of windows xp default theme.I need to write an application which loads some themes from a folder and when one of the theme is selected from the list it is able to set that theme.
Regards
|
|
|
|
|
You can skin your own apps through controlling the repainting of the form. How to do this is out of the scope of a forum post, though.
"I really like comments where I don't have to answer stupid questions" - stfx
|
|
|
|